Automator Error with Add Items to Current Group

I have created a simple PDF Plugin with a single action “Add Items to Current Group.” When I select it from Print -> PDF -> … a pop-up error occurs indicating there was an error with the DT action: “The action “Add Items to Current Group” encountered an error.”

However, the script works as expected despite the error (a PDF document is placed in the current active DT group).

Not sure what is causing the error, but it seems to be related to handling input from the PDF Print Plugin (?)

I cannot get this to work at all. And I also get the error you mention.

Debugging this in Automator, I see the additional (unhelpful) error:


Can't get group record because no window is open in DEVONthink

Very odd - I would take a screen shot but my automator action is simple (I just drag the one action and save). It does work for me, but I do have a DT window open and active in the background.

This should probably be done as an Applescript, which I have done, but oddly this script creates a strange folder in my dock titled “A” which I have to Force Quit every time the script is run. Here is the code, maybe someone can point out a mistake causing the “A” folder to appear:

on open these_items
	try
		if (count of these_items) is greater than 0 then
			tell application id "DNtp"
				launch
				set theGroup to current group
			end tell
			repeat with theItem in these_items
				try
					set thePath to theItem as text
					tell application id "DNtp" to import thePath to theGroup
				end try
			end repeat
		end if
	on error error_message number error_number
		if the error_number is not -128 then
			tell application (path to frontmost application as string)
				display dialog error_message buttons {"OK"} default button 1
			end tell
		end if
	end try
end open

EDIT: I should clarify that this script is placed in ~/Library/PDF Services, and executed by selecting Print… then the PDF drop-down menu in the document you are importing.

This workflow is extremely helpful for me because I’m often editing a document in a particular DT group, and just need to save a PDF copy right back into the same group of the finalized document.

Here’s a solution that so far seems to be working. Create an Automator Print Plugin. The only action to add in Automator is the “Run Applescript” action. The content of “Run Applescript” should be the following:

on run {input, parameters}
	try
		tell application id "DNtp"
			set theGroup to the current group
			set theItem to (item 1 of input) as text
			set theImport to import theItem to theGroup
		end tell
	on error error_message number error_number
		if the error_number is not -128 then
			tell application (path to frontmost application as string)
				display dialog error_message buttons {"OK"} default button 1
			end tell
		end if
	end try
	return input
end run

And that’s it.