I was wondering if there was a way of overriding the default ‘after success’ setting (in my case ‘Trash’), for an individual
case where I want the draft to be kept in ‘Inbox’ and the editor (even though I want the other options to stick with the default). I guess an alternative might be to house the step in a different action with the required ‘after success’ setting, but I was hoping to achieve the outcome within the existing script.
Is this possible?
The after success options on actions essentially set a couple of properties of the draft.
You can set your action to do nothing, and then set one of these properties in the script to specify an alternative outcome under the desired conditions.
As the name implies, “after success” is going to do what it’s set to do if the action completes successfully.
You can control the outcome in your action two ways:
Leave “after success” set to “do nothing”, and use the logic of your script to move the draft if desired. As @sylumer mentioned, you can directly set the
draft.isTrashed values (and
draft.update() to save changes).
Tell Drafts that your action was not successful using
context.fail() (docs). If one of these is called, the action is not considered successful and the “after success” will not be triggered.
@agiletortoise @sylumer I suspected this was the route to go down; however, I didn’t allow for updating the draft and loading a new one in to the editor for one of the cases. Thanks!