Archive a draft depend on a JS prompt

Hi,
Depend a prompt choice, is there a way to archive a Draft only with JavaScript.
Thanks.
Cheers,
Grégoire

Try…

draft.isArchived = true;
draft.update();

Not sure the exact goal - you can set the action’s after success setting to “Ask” and it will prompt each time for whether you want to archive/trash the draft.

Otherwise, you cannot make it conditional without using a script. If you have a prompt in an action, assuming it uses the default key value, the full script step to check for the response and conditionally archive would be something like:

// get the name of the button tapped in the last prompt step
let button = draft.processTemplate("[[prompt_button]]");
// only archive if the user pressed the "OK" button
if (button == "OK") {
    draft.isArchived = true;
    draft.update();
}

Note that the action should be set to “Do Nothing” in after success, or that setting will take affect after the script and possible move the draft.

Thanks for your answer !

Hi !
That’s my goal. I will try ASAP. Thanks