Thanks - that Develop→«mymachinename»→*JSContents menu tip was really helpful.
So I had a poke around with Application().tagsGroups() and got nowhere, and realised I needed to do
Application('DevonThink Pro').currentDatabase().records()[0].properties()
which will get me a list of items I can filter on who may be kind: “Group” with a name: property I’m looking for.
Application('DevonThink Pro').currentDatabase().records()[0].properties()
Somewhere online I got a sense I could filter this list with some probably completely unrelated code, but clutching at straws, I tried it:
Application('DevonThink Pro').currentDatabase().records({match: [ObjectSpecifier().name, 'Uber']})[0].properties()
only to get nothing. And in fact, it just seems to point to the first group in my database anyway, not one of the things I’m trying to use at all.
Coming from another angle, I tried this:
Application('DevonThink Pro').contentRecord().tags()
which at least returned me a JS Array of strings, which felt less threatening to me, code-wise. Maybe, I thought, I could just append the tag as a string, and DEVONthink would step in and do the right thing for me?
Application('DevonThink Pro').contentRecord().tags().length // gives me a number of tags I'd expect
Application('DevonThink Pro').contentRecord().tags().append("Uber")
Application('DevonThink Pro').contentRecord().tags() // does *not* contain "Uber"!
So again, I’m kind of stumped. I’ve tried a few ways to implement bit of cgrunenberg’s suggestion as JS, but in a naïf way, and inevitably tripped.
I’m slowly getting there, but would welcome any suggestions - fully appreciating, now, how undocumented the JXA interfaces are (I can’t call some Applescript from JavaScript, can I? Is that crossing the beams?)