No. createLocation only creates the group if necessary. Otherwise it returns the existing group. I tried to explain that already, sorry if it was unclear.
Your Github link looks like the exact same plug-in code you posted earlier? I don’t see anything related to Shortcuts in it.
To me the simplest solution still seems to be a JXA script like the one I suggested at the start. I don’t get why you’re so focused on using Omni Automation if you only need this to work on macOS?
When I first heard about Omni Automation I was intrigued, but I didn’t know any JavaScript back then. I only took another look now, so maybe I’m missing something.
I’m more familiar with OmniOutliner, so I’ll use that for an example: creating a group hierarchy in DEVONthink from selected outline rows.
With Omni Automation it does seem like I need to use Shortcuts. I build one consisting of two parts:
And then a plug-in calling the shortcut:
(I just used the first template from the link in my previous post)
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "Otto Automator",
"identifier": "com.omni-automation.all.launch-shortcut",
"version": "1.0",
"description": "This action will launch the specified Shortcuts workflow.",
"label": "DEVONthink group hierarchy from selected rows",
"shortLabel": "Rows → DT Group Hierarchy",
"paletteLabel": "Shortcut",
"image": "gearshape.2.fill"
}*/
(() => {
const action = new PlugIn.Action(function(selection, sender){
let shortcutTitle = "DT group hierarchy from selected rows";
shortcutTitle = encodeURIComponent(shortcutTitle);
let urlStr = "shortcuts://run-shortcut?name=" + shortcutTitle;
URL.fromString(urlStr).open();
});
action.validate = function(selection, sender){
return true;
};
return action;
})();
Instead I can do the same with a single, short JXA script:
(() => {
const DT = Application("DEVONthink");
const OO = Application("OmniOutliner");
const sel = OO.documents()[0]?.selectedRows;
if (sel?.length > 0) {
OO.expelAncestors(sel).forEach(row => {
const pathStr = row.rowpath.name().map(
name => name.replaceAll(/\//g, "\\/")
).join("/");
DT.createLocation(`/${pathStr}`,
{in: DT.currentDatabase}
);
})
}
})()
Maybe I could merge the Omni Automation Script from the shortcut into the plug-in code directly to make it shorter, but the pure JXA solution still seems simpler.