Happy Business Starts Here

How to handle multiple failed tasks in workflow.

Zuora Staff

How to handle multiple failed tasks in workflow.

Whenever we do a callout or CRUD in workflows, There is a chance of failing. If we do more that one callout in the workflow, No need to add else at every step like below.




In the above screenshot, we are adding the same exception at every callout check. Instead of using some liquid syntax, we can achieve using a single task.2.png


As per the above screenshot on the finish, we can check on the finish if there are any errors using the below syntax.


{% assign Errors = WorkflowInstance.ErrorTasks.size %}

{% if Errors ==0 %}

Workflow has completed successfully with no errors

{% endif %}

{% if Errors != 0 %}

{{Errors}} task(s) have failed:

{% for WFInstance in WorkflowInstance.ErrorTasks %}

Task Id: {{WFInstance.id }} - {{WFInstance.name }} Error : {{WFInstance.error | remove: "Liquid error: Data Error: Undefined variable Workflow_"}}

{% endfor %}

{% endif %}


using the above liquid code you can send a consolidated email.