Create a selection prompt from items jot down in specific DRAFTS note

I want create a selection prompt from items which are named in another DRAFTS note. One per line. The results should be the item selected, thus the text of the selected item.

Is such possible? And if so, how to archive.

Thanks

So… using an existing draft as the source for a menu / list prompt? And I’m assuming that would result in the text of the selected item being inserted at the cursor in a new draft? Completely possible. I’ll be back in a bit with something I use that works like this…

That would look something like:

// lookup the draft you are using for the options
let d = Draft.find("UUID-OF-DRAFT");
// create a prompt
let p = new Prompt();
p.title = "My Title";

// add lines of draft to prompt as buttons
for(let ln of d.lines) {
    p.addButton(ln);
}
// display prompt
if (p.show()) {
    // display selected item...
    alert(p.buttonPressed);
}

At the end, the selected item is in p.buttonPressed.

Okay, so @agiletortoise beat me to it. And the option he’s put forward is probably the best way to go— gets the job done without any dependencies.

Just in case anyone arrives at this thread from the future and would like an alternative to consider, the way I do this is here:

It depends on (surprise surprise, for anyone who’s seen any of my other recent posts) an MGChecklistPrompt (install from here). Once you’ve got that, insert the UUID for the draft that contains your list options in the appropriate place in the second action step, and you should be good to go.

What particularly like about this option is that it allows you to live filter your list, which is useful if you have a range of items to choose from.

Hope that helps!