Navigating in navigation sidebar using a script and highlighting the selected groupon

Many times when I have multiple document tabs open I would like to see the document in context to its location in the navigation side bar.

So when I am viewing tab1 I want to see the navigation side bar show the group that the document is in and when I switch to a another tab again I would like to see the navigation bar reflect the group in which the current visible document resides.

I wrote a script that does that for me. But for some reason even though the navigation side bar reflects the location of the document but its parent widow is not highlighted.

Here is an illustration when I clicked on the second tab “blogging with hugo” and execute my script it does the navigation properly and the parent group is highlighted.

But when I click on the the first tab “You Tube Videos” and execute my script it while it does the navigation properly but the parent group is not highlighted.

Can someone help me with this.

Also, being new to AppleScript any suggestion to improve the script would be appreciated.

Here is my script.

tell application id "DNtp"
		if not (exists think window 1) then error "No window"
		set the theThinkWindow to think window 1
		if (content record of theThinkWindow) is equal to missing value then error "content record of theThinkWindow is missing value"
		set theDocShown to content record of theThinkWindow
		set parentOfTheDocShown to parent 1 of theDocShown
		set theViewerWindow to viewer window 1
		set root of theViewerWindow to parentOfTheDocShown
		set selection of theViewerWindow to {theDocShown}
	on error theError
		display alert theError
		return theError -- this ends the applescript when an error occurs
	end try
end tell


Your script works over here if the content record is not in the global inbox.

If the content record is in the global inbox then DEVONthink sets the root correctly (the path bar is updated) but it doesn’t update the new root in the navigation sidebar. I guess it’s a bug.

Thanks @pete31 for your help.

By me it just does not always work no matter the parent location. This is true whether or not it is in the global index.

Screenshots before/after using the script and of Preferences > General would be helpful, thank you!



Note: I renamed the global inbox

Deleted my previous post because I had an active search when I took the screen shots, which might cause misleading results.

This works as expected using the latest internal build (but only if the option to automatically expand/collapse the sidebar is enabled).