The `reveal=1` parameter in item links doesn't seem to work reliably

Hello,

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:

  1. Open a DEVONthink window
  2. Navigate to the enclosing folder of the test item and double-click on it, which will open the folder
  3. 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.

Now, what am I going to say about this? :thinking::upside_down_face:

2 Likes

Sorry Jim, guilty as charged! Running on beta OS again.

2 Likes

:point_up_2:t3:I know! I know!

1 Like

Additional note that I should’ve clarified better:

The issue only occurs on my machine when the enclosing folder is opened by double-clicking.

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 result might actually vary depending on the currently visible group and the used view.

1 Like

Thanks for joining the thread, Christian!

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.

It’s actually not selected on both screenshots, did you take them right after revealing?

1 Like

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).

Screenshots of the complete window right before/after revealing would be great to check this, thanks!

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.

1 Like

Can you post your KM script?

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).

1 Like

Thank you for the insight, Christian! I’ll follow your suggestions and improve the script.

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
1 Like

This should be get database with uuid probably.

1 Like

Indeed, however it needs a small tweak…

The get database with UUID command doesn’t support item links, only UUIDs.

Okay. I just thought it would since a get record with uuid does support both.