I mean Smart rule “Track opened documents with Trickster”
The script is simple:
on performSmartRule(theRecords)
tell application id "DNtp"
set dtBundleID to "com.devon-technologies.think" -- DEVONthink 4+
if (version starts with 3) then set dtBundleID to "com.devon-technologies.think3"
repeat with theRecord in theRecords
set itemLink to the reference URL of the theRecord
set thePath to the path of the theRecord
set {recDB, recLoc} to the {name of database, location} of theRecord
set recordPath to ("[" & recDB & "]" & recLoc) as string
set appname to name
tell application "Trickster"
add recent thePath source appname displayPath recordPath callbackURL itemLink bundleID dtBundleID
end tell
end repeat
end tell
end performSmartRule
And work just fine in Script Debugger
But as a smart rule in DT always get an error: can’t get reference URL (the first line to deal with theRecord). Can’t figure out what is the problem…
Which version of macOS & DEVONthink do you use? Is the script part of the smart rule or an external one?
Latest DT and MacOS Tahoe 26.6.1
OEM Script, part of the smart rule, not external. Should I make it external?
What are the conditions of your smart rule? A basic script works fine over here (26.6.2) using both batch processing & smart rules.
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with theRecord in theRecords
set itemLink to reference URL of the theRecord
set URL of theRecord to itemLink
end repeat
end tell
end performSmartRule
Are there multiple versions of DEVONthink installed on your computer?
Condition is on open
I have only one version of DEVONthink installed. And when I copy script to Script Debugger it also works as intended:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
--on performSmartRule(theRecords)
tell application id "DNtp"
set dtBundleID to "com.devon-technologies.think" -- DEVONthink 4+
if (version starts with 3) then set dtBundleID to "com.devon-technologies.think3"
set theRecords to the selection
repeat with theRecord in theRecords
set itemLink to the reference URL of the theRecord
set thePath to the path of the theRecord
set {recDB, recLoc} to the {name of database, location} of theRecord
set recordPath to ("[" & recDB & "]" & recLoc) as string
set appname to name
tell application "Trickster"
add recent thePath source appname displayPath recordPath callbackURL itemLink bundleID dtBundleID
end tell
end repeat
end tell
--end performSmartRule
I’ll try to make an external script if it helps
Does it work without those lines?
The current version of that smart rule is this…