Scripting: create smart group (JXA) does not work

… or at least not as I think it should work.

(() => {
    const app = Application("DEVONthink");
    const r = app.getRecordWithUuid('UUID-of-parent-group');
	const group = app.createRecordWith({name: year, 
			"record type": "smart group", 
	        "search group": r, 
			"search predicates": `name:~ 2026`}, 
			{in: r});
	}
})()

This is supposed to create a smart group as child of the group r selecting all records containing the current year in the name. It does not, however: I get something weird, without any search predicate at all and searching in the database.

I have to set the properties searchGroup and searchPredicates after creating the smart group. Providing them in createRecordWith doesn’t work. At all – not even when copying data from another smart group.

create record with doesn’t support all properties, these ones have to be set by the script so far.

… yields…

There seems to be a difference between JXA and AppleScript in this case.

Indeed but the reason is beyond my mortal knowledge :slight_smile:

It’s just a typo in DEVONthink’s JXA support, the next release will fix this.

2 Likes