Start a workflow with the Start when any workflow errors event

You can start a workflow when another workflow encounters an error by configuring a Start when any Workflow Errors start event. This event can start a new workflow instance when a workflow in your K2 environment goes into an error state. Typically, you would start a workflow to handle errors, or to notify someone about the errors so that they can address or repair the errors.

There are many reasons why a workflow might go into an error state. An easy way to simulate an erring workflow is to send an email to an invalid email address on the Send Email step, for example: bob2denallix.com instead of bob@denallix.com. The workflow runs, fails on the Send Email step, and goes into an error state. To see the erring workflow and error message, browse to K2 Management > Workflow Server > Workflows > [workflow name] > Process Details > Errors tab.

Instead of manually checking error logs, use the Start when any Workflow Errors event to start an error handling workflow to notify someone with an action task or an email. When you configure the Start when any Workflow Errors event, workflow properties from the erring workflow populate as variables in the error handling workflow. These include properties such as Workflow Name, Workflow ID, Folio, Error Message, and more. You can use these variables to populate the body of an email notification, or add details to the instruction section of a task with information from the erring workflow. You can also use the variables in SmartObject calls.

Keep in mind that if you use the Start when any Workflow Errors event, any workflow going into error state will start a new instance of the error handling workflow, and it becomes like a global "catch all" workflow. The global "catch all" workflow approach works in environments with few workflows in error state, and if you keep a simple configuration to the error handling workflow. When your error handling workflow contains multiple steps, such as user and server tasks, you can run into a scenario where potentially thousands of items flood your K2 worklist and email inbox. You could also run into a multiple error state loop. It is recommended to have a simple global "catch all" error handling workflow that sends an email when any workflow goes into an error state. For more specific error handling, use a Conditional Start Rule to start the error handling workflow only if the erring workflow matches certain criteria. For an example on configuring a Conditional Start Rule on the Start when any Workflow Errors event, see the Example of an error handling workflow configured with a Conditional Start Rule section in this topic.

Example of a configured Start when any Workflow Errors event

See the following resources for more information: