JXA: setting color to undefined raises error

While record.color() returns undefined for a tag with the default color, the inverse record.color = undefined throws an error (Types can’t be converted). That is a bit unfortunate.

Also, the scripting dictionary states that color is supported only by “groups and tags”. Is that really the case? I was unable to set the color for a group, neither in JXA nor in AppleScript. Nor is there an UI element to set a group’s color as there is for a tag.

Works at least fine using AppleScript:

tell application id "DNtp"
	set theRecord to selected record 1
	set color of theRecord to missing value
end tell

Yes. But colors of groups can be only changed via AppleScript, only tags are supported by the UI.

I know. And “missing value” gets reliably translated to undefined on get. It would be nice if it worked similarly on set.

I tried this code

tell application id "DNtp"
	set rec to get record with uuid "x-devonthink-item://6C6E44EC-067B-49F1-9732-E39A405E42ED"
	set color of rec to [65535, 0, 0]
end tell

where the record is a group, and the color didn’t change. It does so reliably with tags, however.

Completely handled by JXA, DEVONthink isn’t even called.

Actually just a wrong description in the script suite, it’s only supported by tags currently. I used the wrong build above :grin:

1 Like

Fun fact:
set record.color = null
works in that it sets the color back to the default. Problem solved.

1 Like