Applescript to go directly to smart group..tried but failed..is it possible?

Hi all

im using this code which works for me for groups

tell application id "DNtp"
	set theRecord to get record with uuid "011858D7-BA67-49C3-922B-0EA749F94AAB"
	set root of viewer window 1 to theRecord
end tell

yet when the uuid is a smart group it dosent appear to work. Anyone has any experience with this?

best

Z

That doesn’t work with global smart groups or smart rules.

@cgrunenberg would have to assess this behavior.

The root is always a record but global items in the sidebar are not records. However, opening the item link of global smart groups/rules might be an option.

thx @cgrunenberg. You mean could be an option in a future release or is there a current way to do this?

thx!

Z

This could be already an option in a script.

I do not know the consequence of working with global smart group, but if all u need is to open a window for it:

You can obtain the link by ctrl-click on the group.

tell application id "DNtp"
	set a to "x-devonthink-smartrule://F435E64D-00BB-4556-BA19-XXXXXXXXXX"
	open tab for in viewer window 1 URL a
end tell

Just to be clear what is being opened, I would restructure it like this…

open tab for URL a in viewer window 1
1 Like

perfect guys!

thx @BLUEFROG and @ngan!

last question the current form i have is this

tell application id "DNtp"
	set a to "x-devonthink-smartgroup://011858D7-BA67-49C3-922B-0EA749F94AAB"
	open tab for URL a in viewer window 1
end tell

which opens a new devonthink window, can i just open it in the same window?

also for future endeavors where does one get a list of all devonthink applescript options (such as open tab etc)

thx so much

Z

can i just open it in the same window?

It always opens a new window. @cgrunenberg would have to assess if this is expected.

where does one get a list of all devonthink applescript options (such as open tab etc)

The AppleScript dictionary. In Script Editor press Shift-Command-O and select DEVONthink in the application browser.

It is. Tabs of windows support only records but global smart groups aren’t records.

1 Like

thx @BLUEFROG and @cgrunenberg

now im confused :slight_smile: but maybe im not explaining ti correctly :slight_smile:

i have this AppleScript

tell application id "DNtp"
	set theRecord to get record with uuid "92E76FE0-B6F7-4224-92F2-04721E92946A"
	set root of viewer window 1 to theRecord
end tell

that does indeed move the view for better world to the group i want in the same window. Just to clarify that isn’t possible currently with a smart group, but rather only in a new window?

thx

Z

Just to clarify that isn’t possible currently with a smart group, but rather only in a new window?

According to what Criss said, yes that’s correct.

thx for the info. So to continue my series of question :)…

is it possible to link to a specific .md note and not a group? I tried using the precious merits with a uuid of a note which dosent seem to work

tell application id "DNtp"
	set theRecord to get record with uuid "71E95E98-131D-45DB-AF2C-CF3FBFFDC1AB"
	set root of viewer window 1 to theRecord
end tell

is it possible at all and need code adjustments or just not possible?

can you perhaps using alternative methods for this (such as a url callback?) to open a specific note?

thx!

Z

The root of main window has to be a node (group, smart group or feed). You could open a document window instead or open the document in a tab.

thx @cgrunenberg!

since im only starting with dabbling with applescript, any examples of how to change the above script to do so or a good recommendation to where to learn such things?

Also: can you link to a specific note in iOS (for DTTG) via a url callback?

thx so much for your kind help

Z

The folder ~/Library/Application Scripts/com.devon-technologies.think3 contains many example scripts, others can be found over here. And of course you could have a look at DEVONthink 3’s AppleScript support by dropping DEVONthink 3 onto the Script Editor.app icon in the Dock/Finder.

Item links are identical on both platforms.