const app = Application("DEVONthink 3");
app.performSmartRule({name: "Resources: process inbox"});
But it does nothing, keeps Script Editor running and eventually gives a timeout. When applying this smart rule manually (with 1 item matched) it works without problems. Any ideas what could be going wrong?
(just tested, this also goes awry when using Applescript instead of JXA)
It’s running an external JXA script which is quite complicated. I’ve tried with a simple rule to display an alert and that is showing… So possibly this rule does not run because it’s an external JXA script which is being called?
I know the feeling; most of my rules are complicated Does the rule work if it is not called from a script but e.g. on import? What I am asking is whether it works but any means other than manually. There is (or was?) a difference between manual and triggered execution of rules as I noted here for example.
Yes, it normally triggers on import e.g. and other non-manual events. What I’m trying to do is make sure the rule runs at specific moment if through an external script. I’ve just tried to remove the “Execute script” action from the original rule and replace it with “Show alert” and then it works fine. Maybe @cgrunenberg could answer if there’s anything that could be happening because the smart rule is calling an external script?
Since you mention „timeout“ in the title of the post: You can set a timeout value when calling JXA functions. Apple’s JXA documentation mentions that (and I don’t remember the exact semantics), so you should be able to find it there.
If setting that doesn’t help, I’d suggest to pepper your 2nd external script with app.logMessage() calls or something similar so that you can at least get an idea up to which point it runs.
I’ve created a simplified JXA test script. It seems this has the same result: when I try to trigger the script via AppleScript or JXA with perform smart rule or app.performSmartRule() it gives a timeout (DT3.8.6). Wondering if you get the samen results with this @chrillek@blanc? Btw: it doesn’t seem to matter if it’s an internal or external JXA script.
No, none with the above script. As soon as it triggers it starts beachballing.
When trying with a rule which executes a simple inline AppleScript there are no problems:
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with theRecord in theRecords
log message "Test"
end repeat
end tell
end performSmartRule
Thanks for persevering I also cannot currently test; if it’s reproducibly beach balling though, that is excellent. Criss @cgrunenberg will ask you to sample the process and send him the result, and then - if past performance is any indication of future performance - he’ll come here and go “fixed for the next release”
There were others which targeted the same inbox as this rule (Resources > Inbox). None which targeted the Global Inbox. I’ve now removed all other smart rules and just kept this one. Restarted DT. Same result.