I’m trying to link a DEVONthink item to an OmniFocus item via AppleScript, but when I try the hook command to hook the two bookmarks, I get an error that Hook can’t get bookmark id. What’s odd is that it’s always the second bookmark in the hook command that causes this error regardless of whether it’s DT or OF. In other words, with the item URL for my DT item in the variable dtLink and the task URL for the OF item in ofLink, I do the following:
tell application "Hook"
set myBookmark to make bookmark with data dtLink
set myBookmark2 to make bookmark with data ofLink
hook myBookmark and myBookmark2
end tell
I get the error “can’t get bookmark id” followed by the link for myBookmark2. If I swap myBookmark and myBookmark2 in the hook command, I still get the error on the bookmark after the ‘and’.
I spoke to soon. It seems like the delay gets it to work occasionally, but it still fails most of the time. I’ve tried increasing the delay and adding delays after each hook command. Still no luck. I’ve trimmed down the code to the bare minimum to create an item in DEVONthink and OmniFocus without involving mail. It still fails. Here’s the simpler version:
tell application id "DNtp"
set theRecord to create record with {name:"Test", type:txt}
set theLink to the reference URL of theRecord
end tell
tell application "OmniFocus"
tell default document
set newTaskProps to {name:"Test"}
set newTask to make new inbox task with properties newTaskProps
set taskID to id of newTask
set theTaskURL to "omnifocus:///task/" & taskID
end tell
end tell
tell application "Hook"
set myBookmark to make bookmark with properties {address:theLink, name:"Test"}
set myBookmark2 to make bookmark with properties {address:theTaskURL, name:"Test"}
hook myBookmark and myBookmark2
end tell
Here’s the error I get:
error "Hook got an error: Can’t get bookmark id \"omnifocus:///task/p8Zbd00NKPV\"." number -1728 from bookmark id "omnifocus:///task/p8Zbd00NKPV"
What if you skip the bookmark variables and put the bookmark lines inside the Hook line? That may force it to resolve both bookmarks before Hooking them.
Looking under the hood, we don’t think tinkering further with that AppleScript will do any good. we will further optimize the underlying automation engine in Hook 3.3, due hopefully early Sept. Thanks for all the feedback and sorry for the inconvenience.