Overriding ‘after success’ for a particular case within a script

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.

  • isArchived
  • isTrashed

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.

1 Like

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:

  1. 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.isArchived or draft.isTrashed values (and draft.update() to save changes).

  2. Tell Drafts that your action was not successful using context.cancel() or context.fail() (docs). If one of these is called, the action is not considered successful and the “after success” will not be triggered.

1 Like

@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!