apply an action script in DA search sets

I started with DA&DT mid July08 and I am quite happy with the search sets and the results and the way to drop documents, scans or whatever in DT. I succeeded in sending an email or adding the result to DT. Next trial was to use a script, which creates a new group in DT (having all the results in the top level are not helpful to get an overview). The script works fine, when starting from script editor. It does not work if called by the DT search set. Now I even do not get any longer emails (search set asking for an email) or succeed in adding the result to the top level of DT without creating a new group? What has happened?

Find next the script (created by one of the DT users):

tell application “DEVONthink Pro”
set theGroupName to create location “Daily Customer News/” & (((year of the (current date)) as number) * 10000) + (((month of the (current date)) as number) * 100) + ((day of the (current date)) as number) as string
end tell
tell application “DEVONagent”
search “[search string]” using set “[search set]”
set theSearch to search window 1

	-- Wait until the search has finished.
	repeat until searching of theSearch is false
		delay 5
	end repeat
	set theResults to search results of theSearch
	repeat with theResult in theResults
		set record_name to title of theResult
		set record_url to URL of theResult
		set record_source to source of theResult
		tell application "DEVONthink Pro"
			create record with {type:html, name:record_name, URL:record_url, source:record_source} in theGroupName
		end tell
	end repeat
end try

end tell

Thanks for any support

As this is not an action script, it has to be saved in ~/Library/Application Support/DEVONagent/Scripts. Afterwards it can be executed via the internal Script menu.