Archive a draft depend on a JS prompt


#1

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


#2

Try…

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

#3

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.


#4

Thanks for your answer !


#5

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