Getting DEVONThink 3 to work with Hook

I’ve tried using the scripts discussed here to work in DEVONThink3 in order to “Link to New”

They almost work:

  • a note is created
  • bbedit is invoked
  • upon closing bbedit, I’m left with the note in the group i want (in my case, the higest level inbox in DT3)

BUT:

  • the initial item, when I invoke Hook again, does not refer to the note i just created
  • ditto for the new note. It doesn’t know where it comes from !

After digging around, I realized the “New Document” script is supposed to return the link at the end. So I thought that maybe the get reference URL of newItem line was not enough to return said reference. I borrowed a trick from @RobTrew in his last post on Quiver: simply invoke the variable you want to return at the end of the script.
So this is what my new “New Document” script looks like:

--this is the UUID of the high level inbox
property folderID : "EEAD2856-F3D0-494B-AE80-AC9E13422082"
--set the date in ISO format
set the_mon to month of (current date) as integer as string
if (count characters in the_mon) = 1 then set the_mon to "0" & the_mon
set the_day to day of (current date) as string
if (count characters in the_day) = 1 then set the_day to "0" & the_day
set the_date to (year of (current date) as string) & "-" & the_mon & "-" & the_day
-- get nicer content and format strings
set the_title to "$title" & "-notes"
set the_content to "# $title\n\n## " & the_date & "\n\n"

tell application id "DNtp"
	set newDocGroup to get record with uuid folderID
	set newItem to create record with {name:the_title, content:the_content, type:markdown} in newDocGroup
	set the_url to (get reference URL of newItem)
	set itemPath to path of newItem
end tell

tell application "BBEdit"
	open itemPath
	activate
	tell application "System Events"
		key code 125 using {command down}
	end tell
end tell

(the_url as string)

This ALMOST works: the item i link to now knows where to find the devonthink note. But i’m left with two wrinkles:

  • the new note doesn’t have a callback to the original item
  • by pasting the url at the end of the script, I’m actually INVOKING devonthink to open the note at the same time as BBEdit is opened …

Any ideas?
Cheers.

My guess is that launching BBEdit from inside the embedded Link to New script is preventing that script from eventually returning the DT3 reference URL.

Could you step back and sketch the use case and how you want the the workflow to work ?

What app are you running when you choose Link to New in Hook ? BBEdit ?

Is the idea to establish a link from one BBEdit/Text file to another (stored in DT3) ?

Or am I getting the macro-picture a bit wrong ?

the new note doesn’t have a callback to the original item

If you use the scripts from this page, the address Hook gets from BBEdit will be different from the address that Hook gets from DEVONthink, and since links use these addresses, Hook won’t show links to a document open in BBEdit, if they’re made with the document in DEVONthink, it considers them two different items.

If you don’t use the scripts on that page Hook will recognize that its the same file everywhere, but it will open links in the default app for file type.

The advantage of using those custom scripts is that links open the document in DEVONthink, the disadvantage is that it treats document as if they are a different than the files themselves.

Another issue might be that the Link to New scripts on this page don’t reformat the URL scheme from x-devonthink-item to devonthink, so they’re not compatible with the Get Address and Open Item scripts
If that is the problem you can add this line to convert the_rul before returning it: set the_url to "devonthink" & text ((length of "x-devonthink-item") + 1) thru -1 of the_url

1 Like

Thanks for replying.
The general idea is to store my notes from anywhere in DT3 (DT3 would be the default “link to new” app), with a name that’s almost identical to the name of the item i’m linking from (a file in finder, an email in outlook, etc …)

I think I understand your point about different adresses. The issue I was facing was that DevonThink3 did not appear in Link to New if there are no scripts. I’m assuming DT2 did?

That works! I now get the link to the DT3 note when I invoke hook from the original item, and to the original item when I invoke hook from the note in DT3.
Even with the bug of DT3 opening at the same time as BBEdit, it’s now serviceable for me.

Thanks!

2 Likes

I might be confused by the different versions of the scripts posted here. I’d appreciate it if someone posted versions that works (i.e. that retains the link correctly). Thanks@

1 Like

We will post on the forum when we update the integration scripts server, so that users can automatically get updates. those updates are not applied if the user has locally overriden the built in script. Overridden scripts are marked with an asterisk (*). Users who have overriden a script may select said script and hit the “-” button below the scripts list to clear their override and get the script provided by CogSci Apps.

Hi There, FYI, @grahamb has updated the documentation page’s, Customizing Hook integration with DEVONthink – Hook introduction to try to better explain the difference between linking to files in DEVONthink and linking through the database. He also improved the example scripts, to be simpler and easier to understand.

The default scripts aren’t optimal for linking to entries that are in the database per se (as opposed to indexed).

We’re considering improvements, such as providing a way to get the best of both worlds: e.g., for “get address” to return an address that is based on the location of the file, and for this option not to require users editing scripts; and other enhancements. (Similar considerations apply for other personal information managers).

The link does not work, was it removed?

welcome to the Hook Productivity Forum, Riccardo.

Hook does not currently have built-in scripts for DEVONthink. However, we are about to release some for DEVONthink 3. In anticipation of that we’re in the process of moving the DEVONthink sample scripts to the help2 section: https://hookproductivity.com/help2 .

It may be worth waiting for the new DT scripts to be built in ? Within a week if all goes according to plan.

(On a related note, we recently released updated EagleFiler scripts, and will be publishing a blog post about that.)

We’ve archived the information here: Historical Information about Customizing Hook for Usage with DEVONthink – Hook.

The DEVONthink 3 integration scripts will be released soon on Hook’s integration server, meaning if you have auto-updates setup you’ll get them automatically.

1 Like