As documented in the manual, you can reveal an item in its enclosing group by using a parameter, e.g.
x-devonthink-item://<uuid>?reveal=1
While incorporating this feature into my workflow, I noticed that it occasionally opens the enclosing group without also selecting the corresponding item at the same time. Here’s how to reliably reproduce the issue on my end:
Open a DEVONthink window
Navigate to the enclosing folder of the test item and double-click on it, which will open the folder
Now open the item link of the test item
Expected result:
In the DEVONthink window that already has the enclosing folder’s content visible, the test item is selected
Actual result:
No visible change in DEVONthink’s window
I’m running DEVONthink Pro 3.8.5 on macOS Ventura 13.0(22A5311f). Thank you in advance.
If I navigate into the folder only using left-clicking, which will show the folder in the complete hierarchy, the reveal=1 parameter will work reliably.
The visible group is always the one enclosing the test item corresponding to the item link, and I’m using the “as Columns” view mode and “Standard” preview mode. I have not tested with any other combinations of view modes and preview modes.
Is the current behavior an intentional design? It struck me as very confusing since I expect the corresponding item to always be selected/highlighted when I go to the x-devonthink-item://<uuid>?reveal=1 item link.
Oh, sorry for the confusing screenshots! I did not take those two screenshots after clicking the item link; instead they were taken purely for the purpose of demonstrating the two different “views” (not sure what the correct DT terminology should be used here).
While I was preparing the screenshots, I discovered that the issue was actually not reproducible using the test database/groups/records I manually created for the screenshots.
When I encountered this unexpected behavior during actual daily usage, I was using a Keyboard Maestro script that creates a new record and then immediately attempts to open the ?reveal=1 item link. I just tried inserting a delay 1 line between those two lines and now the corresponding record is correctly selected, albeit after the 1 second delay.
Hi Jim, of course! I thought the whole script wouldn’t be necessary but here it is:
-- pass the variables from KM engine to the AppleScript script
tell application "Keyboard Maestro Engine"
set theID to getvariable "ZettelID"
set theTitle to getvariable "Title"
set theNote to getvariable "Note"
end tell
tell application id "DNtp"
tell database id 3
-- create new record in the predefined group using previous variables
set theGroup to (get record with uuid "E9250DA0-5DB5-4083-B4A8-E07A65E863D2")
set theRecord to create record with {type:markdown, name:theTitle, aliases:theID, content:theNote} in theGroup
-- delay 0.5s and reveal the record in DT
delay 0.5
open location (get the reference URL of theRecord) & "?reveal=1"
activate
end tell
end tell
Item links are usually only intended for clickable links, especially in external apps. In case of AppleScript you could set the root of the frontmost viewer window to theGroup and change the selection of the window to {theRecord}.
However, this…
tell database id 3
…is actually neither necessary nor recommended, databases should never be referenced via the runtime ID (as it might and will change after closing/opening databases or relaunching the app).
Indeed talking to the database directly is the simplest…
tell application id "DNtp"
tell database "Active"
-- do stuff
end tell
end tell
If you plan (or are inclined) to renaming the database, you can use the database’s item link.
tell application id "DNtp"
set db to get record with uuid "x-devonthink-item://E1CB76A0-7EF9-4E2D-B167-AF38923A24FD"
tell db
-- do stuff
end tell
end tell