Simple embedded javascript in smart rule not working

For some reason, that simplest javascript embedded in a smart rule won’t work (‘here’ does not popup in the logs; on DT 4.2.2, macos 26.3.1):

function performsmartrule(records){ 

	const app = Application("DEVONthink");
	app.includeStandardAdditions = true;
	app.logMessage('here');

}

I cleared cache, restarted DT.

Any idea why?

How did you trigger the smart rule? I just tried a batch configuration (a selection is required) and the message was logged.

I tried triggering it by:

  1. “apply rule” from the contextual menu of the smart rule
  2. “every minute”
  3. drop group on the smart rule

nothing worked.

If i replace it with its equivalent embedded applescript, it works in all 3 ways:

on performSmartRule(theRecords)
	tell application id "DNtp"
		log message "hello"
	end tell
end performSmartRule

What matching criteria are you using for the smart rule itself?

I tested with this:

All 3 ways of triggering that you mention work here. (DT 4.2.2., macOS 13.7.8)

Edit: Wait, this was about an embedded script. Guess I got confused when you mentioned clearing the cache and restarting—only external scripts are cached, if I remember correctly.

I tested again using an embedded script. Same result: all 3 ways work.

Thanks @troejgaard for your test. However, if I understand smart rules well enough, matching criteria aren’t the culprit:

  • my smart rule lists the expected groups;
  • dropping a record on the smart rule bypasses matching criteria (afaik)

You’re right, I just checked the manual:

  • Tools > Apply Rules: This runs the actions of a chosen rule on selected items, but only ones matched by the smart rule.
  • Tools > Perform Rules: This performs the chosen rule as defined, not acting on the selection.

Drag and Drop: Lastly, you can drag and drop items onto smart rules to apply their actions to them. Dropped items will be acted on, ignoring the location and criteria specified in the smart rule.

The question remains: why does it not work on your system?
It’s strange. Perhaps some Tahoe bug?

Upgraded to Macos 26.4 : no more issues.

Case closed, thx everyone for the support.

2 Likes