Best practice for error handling in a workflow

Hello all,

New (bubbler?) here, trying to work out the best method of handling errors during a workflow.

Essentially, when running a workflow I want to check for:

  • X is not equal to
  • Z is not equal to

Then run the rest of the workflow.

My understanding is that the workflow execution sequence isn’t done sequentially, like that the UI shows (this was quite a gotcha when I read about this, I digress…).

Taking the below example:

How can I stop Step 3, 4 and 5 from running if the alerts are fired?

Normally I would have access to a “Result of Step X”, but this doesn’t look possible for Alerts.

I can probably put something together to get expected behavior which includes many duplicate “When” conditions on each step, but surely there’s a better method of doing this.

Hopefully that makes sense.

Thanks
Michael

For anyone visiting this thread in the future, came up with my own solution.

My solution is this…

  • Create an alert element on page to let users know what went wrong
  • At the beginning of my workflow I set the state on that Alert element (isError = false)
  • If any of my possible error conditions that run after are true I set state on that element (isError = true)
  • The “work actions”, run based on whether isError = true

There’s probably a better solution, but that works for me and means I don’t need to duplicate “Only when” conditions

1 Like

You could also use the ‘Terminate Workflow’ block and place your conditional on this step. This would avoid you having to place a conditional on every workflow step and is generally more maintainable/efficient.

You’re completely right that there is no guarantee that workflow steps will run and complete in order, however the ‘terminate workflow’ step will not allow any steps to run after it.

2 Likes