Make multiple selections in the group selector

I would like to create a record in multiple groups. Is there a way to change group selector behavior to allow multiple selections and return a list of groups?

I imagine this would require changes to code internal to the class, so I’ve written my own crude version. But with that, I need a simple way to create the nested list of groups.

Any suggestions on either of these 2 solution sets?

Thanks,
Michael

P.S. I’m trying to quickly “code” text snippets from focus group transcripts and map them to the appropriate groups. I’m a newbie and would be interested in learning of others who have done something similar.

If I understand your post, you’d like to take a selection of database records and replicate them to multiple groups? One way to script this is via UI scripting the “Groups & Tags” floating window:

-- Takes possibly multiple source selections in a DTPO database,
-- and possibly multiple selections in the "Groups" window;
-- then replicates source to targets.


tell application "System Events"
	tell process "DEVONthink Pro Office"
		set selState to selected of rows of outline 1 of scroll area 1 of window "Groups"
		set selName to value of text field 1 of rows of outline 1 of scroll area 1 of window "Groups"
	end tell
end tell

set targetGroups to {}
repeat with i from 1 to count of selState
	if item i of selState is equal to true then
		set end of targetGroups to item i of selName
	end if
end repeat

tell application "DEVONthink Pro"
	set sourceRecord to (selection as list)
	repeat with i in sourceRecord
		repeat with j in targetGroups
			set targetRecord to record j of database 1
			replicate record i to targetRecord
		end repeat
	end repeat
end tell

I revisited this script to make the selection faster, but I’m not sure that this is the correct version. (The faster version may be in Python.) Also, this was written in the “pre-Tag” era of DTPO, so perhaps the UI has changed.

Anyway, perhaps a thought for you…

HTH, Charles

Thanks for your quick reply. Actually, I’m creating a new record with text from the clipboard, but need to assign multiple groups to it. I’ve built a query that will prompt the user with the list of groups, but it looks lousy since it’s just a flat list rather than the tree shown in the DEVONthink’s group selector.

I like your idea of brute force multi-selecting groups in the DEVONthink window. Unfortunately, with DEVONthink 2.0.3, I get the following error message:


get selected of every row of outline 1 of scroll area 1 of window "Groups" of process "DEVONthink Pro Office"
		--> error number -1728 from window "Groups" of process "DEVONthink Pro Office"
	display alert "DEVONthink Pro" message "System Events got an error: Can’t get window \"Groups\" of process \"DEVONthink Pro Office\"." as warning
		--> {button returned:"OK"}

I suspect the window names have changed since this was written. I’m a Applescript newbie and really need a debugger/interpreter so I can poke around. I imagine there is a way to determine the system name of the current app windows…any ideas?

Windows are named from their titles (pretty sensible, huh?) so I would try “Groups & Tags.”

Let me know if it doesn’t work for you, and I’ll try to address this later today…

Best, Charles