Hook should be able to link to DEVONthink groups

When a group (folder) is selected in DEVONthink’s sidebar, Hook say’s “no linkable item”. All documents and groups (including tags) in DEVONthink have an “Item Link” that is discoverable via OSA script. So, Hook should be configurable to find the URL of a group.

Sample, which works when the item selected is a group in the sidebar.

tell application id "DNtp"
	set theSelection to the current group
	set theURL to the reference URL of theSelection
	set the clipboard to theURL
end tell

Katie

3 Likes

Any further thoughts on this?

No changes over here. It still looks to me that the DEVONthink 3 Hook scripts for Get Name and Get Address should work for group selections but are not working. Hooking to groups is a good use case – it is too bad it is not supported for whatever reason. Maybe CogSci and DEVONtech could do a bit of collaboration to help us users?

Be Safe
Katie

1 Like

In the meantime, a workaround is to create any type of document you wish and use it as an “anchor document” hooking multiple items to it as you would if you could hook to a Group.

So if you wanted to have a Devonthink Group called “Interesting notes” you can create that group now and then inside that group create Markdown file called “Notes Anchor” and then hook all of your desired notes to that anchor file.

2 Likes

Sorry this fell through the cracks. @grahamb’s in Jan 2020 updated our internal issue database about this, but I forgot to update the issue’s milestone and communicate:

Works on groups. If a group is selected in the sidebar, and no items within are selected, Hook links to the group.

Also other such categories (tags, rules, inboxes, etc).

Does not work on global smart groups or global smart rules. Seems like a bug, because it works with other globals (tags, inboxes) and works with smart groups and rules which are within databases. I’ll send a message to devs, but it’s a very minor issue.

I myself have not dug into this.

I am unable to get that to work

I believe that is a feature, not a bug, because global smart groups and global smart rules are not records.

See https://discourse.devontechnologies.com/t/global-smart-group-uuids/54230

No. That does not happen.

With a group selected and no items within the group are selected Hook does not link to the group. It reports:

Screenshot of Hook (10-2-20, 6-37-36 AM)

I would see nothing wrong with Hook linking to DEVONthink SmartGroups, etc. – but would prefer that the linking to ordinary groups work before anything else is explored, please.

Be Safe
Katie

Thanks both. I’ve passed it back to our developers to have a look.

1 Like

Hey @katie_v, @rkaplan,

I’ll need your help to debug this because I can’t seem to reproduce the issue with my current arrangement of settings and databases in DEVONthink.

Fortunately, I do think I have a fix, I’ll just need you to test it for me. Do you have any experience with editing Hook scripts? If you open Preferences>Scripts and then scroll down the list to select “DEVONthink 3” you can edit the integration scripts Hook uses to get the name and address of records in DEVONthink.

Copy and paste to replace the Get Name and Get Address scripts in the preferences window with the following, and make sure you click Save when you’re done:

Get Name:

tell application id "DNtp"
	if exists (content record of current tab of window 1) then
		-- current open item
		return name of (content record of current tab of window 1)
	end if
	
	if class of window 1 is in {viewer window, search window} then
		set selected_items to selection of window 1
		if (count of selected_items) = 1 then
			-- current selected item
			return name of item 1 in selected_items
		end if
	end if
	
	-- selected group
	set theSelection to the current group
	return name of theSelection
end tell

Get Address:

tell application id "DNtp"
	if exists (content record of current tab of window 1) then
		-- current open item
		return reference URL of (content record of current tab of window 1)
	end if
	
	if class of window 1 is in {viewer window, search window} then
		set selected_items to selection of window 1
		if (count of selected_items) = 1 then
			-- current selected item
			return reference URL of item 1 in selected_items
		end if
	end if
	
	-- selected group
	set theSelection to the current group
	return the reference URL of theSelection
end tell

These new scripts are almost the same as the old, but I’ve replaced the section which is supposed to get the selected group (the lines at the very bottom) with some code based on the snippet that @katie_v included in the original post.

Let me know if these make a difference!

1 Like

Thanks for the effort - but I still get this for any groups - it works for other items.

image

Sorry @grahamb, the revised scripts result in the same “No linkable item found…” message. I’ve tried this in all the possible configurations of panels and windows in DEVONthink.

If I run the Get Name script in Script Debugger, with a group selected, the following error occurs:

Screenshot of Script Debugger (10-4-20, 8-07-48 AM)

I do not get the error when a document is selected in DEVONthink 3, nor when I run the Get Address script in Script Debugger.

Sorry, I don’t know any more than that.

Be brave!
Katie

1 Like

Why not just ask Criss Gruenberg, chief developer at DEVONtechnologies, how to script this? It must be possible.

Katie

1 Like

Thanks for your patience, I’ll definitely reach out to Criss if this doesn’t work, but based on your Script Debugger error, I think I might have figured out where the issue was. Do me a favour and try these scripts:

Get Name

tell application id "DNtp" -- "DEVONthink 3"
	if exists (content record of current tab of window 1) then
		-- current open item
		return name of (content record of current tab of window 1)
	end if
	
	if class of window 1 is equal to viewer window then
		set selected_items to selection of window 1
		if (count of selected_items) = 1 then
			-- current selected item
			return name of item 1 in selected_items
		end if
	end if
	
	-- selected group
	set theSelection to the current group
	return name of theSelection
end tell

Get Address

tell application id "DNtp"
	if exists (content record of current tab of window 1) then
		-- current open item
		return reference URL of (content record of current tab of window 1)
	end if
	
	if class of window 1 is equal to viewer window then
		set selected_items to selection of window 1
		if (count of selected_items) = 1 then
			-- current selected item
			return reference URL of item 1 in selected_items
		end if
	end if
	
	-- selected group
	set theSelection to the current group
	return the reference URL of theSelection
end tell
2 Likes

That works well! Many thanks for the help

3 Likes

Yes! Those scripts are working fine. Sweet!

I had to quit and restart Hook for them to work for me. I don’t know why. But if you can release them in the next Hook scripts update, please, we would be done with this issue I think.

Lovely support!
Katie

2 Likes