Opening an Smart Group with AppleScript

In this post AppleScript was provided to open an item in Devonthink.

I now wish to open a Smart Group with AppleScript but when run in AppleScript I get a message within AppleScript to say there is a 'Missing value" and the contents of the Smart Group are not shown in Devnonthink.

property pUUID : "990AD08B-F92B-42CD-B9B2-A99CE8AC88AE"
-- x-devonthink-smartgroup://990AD08B-F92B-42CD-B9B2-A99CE8AC88AE

tell application id "DNtp"
	set theDoc to get record with uuid pUUID
	open window for record theDoc
end tell

Is it possible to open a Smart Group from AppleScript?

macOS 12.2 - DEVONthink 3, version 3.8.1

With open window for record it’s only possible to open Smart Groups inside a database (i.e. you can’t open global Smart Groups this way).

To open a global Smart Group use do shell script:

-- Open global Smart Group

property theReferenceURL : "x-devonthink-smartgroup://B47C2D2D-3B9A-4EE5-B3B7-172AC2FE7799"

do shell script "open " & quoted form of theReferenceURL


Thank you very much for the information.

Interestingly, the same code also seems to work to open a smart group or regular group within a database.

Sure, but it’s probably slower as it uses do shell script. I would only use this when necessary and for everything else DEVONthink’s open window for.