Query database via AppleScript // Getting several UUIDs for same group

I am querying DEVONthink via AppleScript, and in trying to read - among other things - the UUID of the group, I get several resulting entries for the same group with varying UUIDs.

Here’s my AppleScript:


tell application id "DNtp"
	set resultList to search "name:vagrant* kind:group"  -- Searching for groups named "vagrant" 
	set results to {}
	repeat with result in resultList
		set rName to get name of result
		set rUUID to uuid of result
		set rPath to path of result
		set rParent to name of parent of result
		set rDBName to name of database of result
		set results to results & [{title:rName, mydb:rDBName, myparent:rParent, myuuid:rUUID}]
	end repeat
	return results
end tell

Some of the results have different UUIDs for the same group in the same database:

(omitting many results)

{title:"Vagrant - Homestead", mydb:"Inbox", myparent:{"Deployment related"}, myuuid:"6B20B127-9949-4659-A11D-490D45E4F87B"}, 
{title:"Vagrant - Homestead", mydb:"Inbox", myparent:{"Deployment related"}, myuuid:"9959E96D-589E-4C37-80E8-A161822CAF51"}, 
{title:"Vagrant - Homestead", mydb:"Inbox", myparent:{"Deployment related"}, myuuid:"EA2D5A38-9B03-42FE-9B1F-07A7353866E4"}, 

(omitting some more)

{title:"Vagrant - Setup Box", mydb:"Inbox", myparent:{"Deployment related"}, myuuid:"338C8ACE-17B0-4508-90DD-26CE9B0B004D"}, 
{title:"Vagrant - Setup Box", mydb:"Inbox", myparent:{"Deployment related"}, myuuid:"548D9791-1350-4C45-BECB-02E27A22DB13"}, 
{title:"Vagrant - Setup Box", mydb:"Inbox", myparent:{"Deployment related"}, myuuid:"5E3F816B-2F95-4347-A729-57DAAB1A031D"}, 

(...)

Do the search in DEVONthink’s toolbar search. Do you have multiple groups named the same?

PS: result by itself is a reserved word in AppleScript. Though it works here, I’d suggest renaming it, for example…

tell application id "DNtp"
	set the_resultList to search "name:osticket* kind:group" -- Searching for groups named "vagrant" 
	set the_results to {}
	repeat with the_result in the_resultList
		set rName to get name of the_result
		set rUUID to uuid of the_result
		set rPath to path of the_result
		set rParent to name of parent of the_result
		set rDBName to name of database of the_result
		set the_results to the_results & [{title:rName, mydb:rDBName, myparent:rParent, myuuid:rUUID}]
	end repeat
	return the_results
end tell
1 Like

Out of curiosity: Why does one use
set rName to get name of ...
but
set rUUID to uuid of ...
Put differently: Why does one have to use get with one property and not with another one? The only difference I can see in the documentation is that name is r/w whereas uuid is r/o. Both are of type Text.

My fault. Apparently I had three copies of the same files/subfolders.

get isn’t necessary, it’s just a more descriptive alternative.

Off-topic: Any Objective-C references for a complete beginner with no coding background? Would propably be very helpful in learning AppleScriptObjC. Bonus points if it’s in german.

Actually I can’t tell you any, I never read such a book (or any book about Objective-C).

1 Like

Like “really” or “actually” in human conversation – superfluous, but kind of lubricating.