Can't log name of record via Smart Rule Script

Yes. I am sure. You might look for examples here in the forum.

But your example throws an error here, too. Even if I get rid of the const main ... main() construct that’s not needed here. Could be one of the weirdnesses of JXA, because the script runs just fine in the Script Editor.

Sorry, I didn’t mean it in a harsh way. Thank you for testing it ! I will look at the examples.

Yes, the script runs fine in Script Editor.

I just tried with this template script:

function performSmartRule(recs) {

  const app = Application("DEVONthink 3");

and I get:

08:53:09: ~/Library/Application Scripts/com.devon-technologies.think3/Smart Rules/test.scpt on performSmartRule (A identifier can’t go after this identifier.)

With this script:

function performSmartRule(records){
	return 'Hello World'

I get:

08:57:29: ~/Library/Application Scripts/com.devon-technologies.think3/Smart Rules/po.scpt on performSmartRule (Error -1708)

Perhaps I am missing something ?

I’m really puzzled. I tried the same examples as you, and even an empty function throws error -1708.
Just to make sure, I ran my JS script mentioned in the other thread and linked to above – no problems at all.
Maybe @cgrunenberg or @BLUEFROG can shed some light on this?

For DEVONthink it makes no difference whether a script is actually AppleScript or JavaScript. But the internal script editor doesn’t support JavaScript due to limitations of Cocoa, therefore I would actually discourage to mix different script languages (e.g. in case of smart rules & reminders).

But this example is pure JavaScript, isn’t it? And it’s also an external script (or at least I tried this with an external script, so DT3’s script editor want involved.

I also tested it as an external script and found those errors.

DEVONthink doesn’t even know whether a script uses JavaScript or AppleScript, it always receives the same events (or at least should). Whatever is going on seems to be an issue of JXA which I wouldn’t recommend actually due to its poor state and uncertain future.