Drafts Script - Wait for action to complete

I’m writing an action in Drafts which uses a Script step to find an existing ‘Mustache’ draft, load it into the editor and then run another action (which processes the loaded draft).

This works fine, but I want ‘pause’ the script until the action completes, then do more with the new draft created by the Mustache processing action. Am I right in thinking that I need to use async?

let d = Draft.find("0DE132A1-EC9A-4EB0-987F-B4B64FB6694F");
editor.load(d);

let a = Action.find("Mustache Prompt");
app.queueAction(a, d);

// I want to add extra code here to do more things with the new draft created by the "Mustache Prompt" action, but need to know how to wait for that action to complete (so that the new draft is present in the editor

I suspect you will get all the answers you need from the post on the Drafts forum for this particular Drafts focused question. I can see Greg has already replied.

1 Like

Thanks Steven. Automators is always my first port of call for great help but in this instance I remembered (after posting here) that the Drafts forum is also very good. Thanks for linking to my post there, hopefully it will help others.

Just a quick update to let you know that Greg has helped me to resolve this issue so there may be helpful information over on the Drafts forum for anyone with looking to do something similar. In particular, there is a helpful point about the draft variable and how it can be different from the draft loaded in the editor.