How can I get a smart rule to trigger when creating from templates?

I have a short AppleScript program that, among other things, creates a new document from a template:

set newRecord to import templatePath to current group

In DEVONthink 3, I also have a Smart Rule with a trigger condition “on creation” and “on import”:

Untitled

Despite this, the rule does not trigger when a document is created using the AppleScript code. The rule does work when I create documents using Data ➜ New from template with the same files that my AppleScript code uses. Also, there is nothing special about the template files – they’re just files, without scripts within them.

What is the correct way to have the Smart Rule trigger in this situation?

Actions like this from AppleScripts do not trigger smart rules.

If you’re importing the template via AppleScript, it seems likely you can add the smart rules steps to the script itself.

Bummer! Would have been nice and efficient to leverage the Smart Rule facility. But not it’s not a show-stopper.

Out of curiosity, is there a technical or security reason not to allow script actions to cause Smart Rules to trigger?

There are actually at least two good reasons:

  1. Smart rules could make the results of scripts and smart templates absolutely unpredicatable (both for users and support)

  2. The intention of scripts and when an action is complete and the rule should be triggered therefore is unknown. However, since version 3.5 scripts or smart templates can use the perform smart rule command to add support for smart rules.

1 Like

Thanks for the tip about perform smart rule. I missed this new feature. I just tried it and it worked perfectly!