The action I see in my version of Drafts is simply this
x-devonthink://createMarkdown?title=[[title]]&location=''&text=[[body]]
and there’s nothing you could do to this command URL to have it open a group selector, I think.
After some investigation, I came up with this Drafts Action. It consists of a single “Run AppleScript” step which executes this code
-- AppleScript content
-- Editing and testing in Script Editor recommended
on execute(draft)
set t to title of draft
set c to content of draft
tell application id "DNtp"
set targetGroup to display group selector "Select group to save MD document to" with name
set rec to create record with {type:markdown, name:t} in (selected group of targetGroup)
set plain text of rec to c
end tell
end execute
The code is minimally tested, in that I run it to copy a single MD document to a group.
I apologize for any bad AS code here, as I’m not an AppleScript person.
But it is impossible to do that in JavaScript because Drafts does not support JXA. Not the only weird thing about it, IMO.
In case someone is wondering about the two-step record creation (creation first, setting the plain text
later): I tried to incorporate that into the create record with
command, but got an error because of newlines in the text. I don’t know if that is a bug or a feature.