Flow error handler
Summarize
Summary of Flow error handler
The Flow error handler feature in ServiceNow enables flows to automatically catch, identify, and respond to errors during execution. By activating the error handler, customers can run a defined sequence of actions and subflows to log error details, send notifications, and perform corrective operations. This automation reduces the need for manual troubleshooting and record updates when flow errors occur.
Show less
Key Features
- Error Handler switch: Allows enabling or disabling flow error handling, which reveals the Error Handler section in the flow.
- Error Handler section: A dedicated section where up to 10 items (actions, flow logic, or subflows) can be configured to run upon error detection to automate identification and resolution.
- Error Status object: Provides detailed data pills including an integer error code and a string error message, helping pinpoint the cause of errors.
- Custom error codes: Supported when creating custom actions, allowing precise error signaling.
- Enhanced flow states: When error handling is enabled, flows can have states like Completed (error caught) or Completed (error skipped), improving visibility into error outcomes in execution details.
- Subflow error handling: Subflows can have their own error handlers to prevent errors from affecting parent flows and to manage complex error handling beyond the 10-item limit.
How It Works
When an error occurs in a flow with an active error handler, the main flow execution halts, and the configured error handler section runs. If the error handler processes successfully, the flow ends with a Completed (error caught) state. If the error handler itself encounters an error, the flow ends with an Error state. Flows cannot retry or resume from the error step, but using Try flow logic can allow continuation within defined blocks.
Best Practices for ServiceNow Customers
- Keep error handling logic within the dedicated Error Handler section, not in the main flow, to ensure error handling actions always run.
- Utilize the Error Status object to capture detailed error information for diagnosis and remediation.
- Use subflows to manage error handling beyond the 10-item limit and to create reusable corrective sequences.
- Suppress subflow error messages by enabling error handlers in subflows with empty error handling sections to avoid cascading errors.
- Create custom actions that intentionally throw errors to test and validate flow error handling behavior.
Benefits for ServiceNow Customers
- Automates identification and logging of flow errors as they happen, saving time on manual searches.
- Enables automated corrective actions that update affected records, reducing manual interventions.
- Improves flow reliability by clearly handling errors and providing actionable status codes and messages.
- Supports modular, reusable error handling through subflows.
Enable flows to catch errors. Run a sequence of actions and subflows to identify and correct issues. For example, have flows log output values, send notifications, and run corrective subflows when they produce an error.
Benefits
- Automate the identification of flow errors as they happen. Capture and push flow error information rather than manually search for issues caused by flow errors.
- Automate the resolution of flow errors. Run actions and subflows to update records rather than manually updating records affected by flow errors.
- Build your own action error handling logic. Specify when actions return an error rather than always return an error.
Error Handler components
- 1. Error Handler switch
- Option to enable or disable flow error handling. When enabled, the flow displays the Error Handler section.
- 2. Error Handler section
- Section of flow that runs when the flow catches an error. Use this section to
automate the identification and resolution of flow errors. You can add up to 10 items
in this section.Note:The 10-item limit includes any combination of actions, flow logic, or subflows.
- 3. Error Status
- Object data pill containing details about the error caught by the flow.
- 4. Error Status > Code
- Integer data pill indicating whether the flow produced an error. By default, a value of 1 indicates that the flow produced an error. A value of 0 indicates that the flow ran successfully. You can define your own error codes when you create a custom action.
- 5. Error Status > Message
- String data pill containing the error message produced by the action, step, or system operation.
Available error states
Enabling the Error Handler changes the states reported in the flow execution details. The Error Handler can produce these flow states.
- Completed (error caught)
- State generated when the flow caught an error and successfully ran the items in the Event Handler section. The flow generates this state even when the Event Handler section is empty. This state is only available when you enable a flow Error Handler. This state is only visible from a flow execution details page. Flow context records instead display the state as Complete.
- Completed (error skipped)
- State generated when a custom action continues running after a step failure. When an action generates this state, it passes it to the parent flow. This state is only available when you enable a flow Error Handler. This state is only visible from a flow execution details page. Flow context records instead display the state as Complete.
- Error
- State generated when an error remains uncaught.
- An error occurs in the flow while the Error Handler is disabled
- An error occurs in the Error Handler section
When an error occurs
When an error occurs in a flow with an active error handler, the flow stops running further actions and flow logic and instead runs the items in the error handler section. If the items in the error handler section run, the flow stops with the Completed (error caught) state. If the error handler itself generates an error, the flow stops with the Error state.
A flow cannot rerun items that generate an error or resume from the step that generated an error. You can use Try flow logic to continue running a flow that encounters an errors within the try block.
Flow and action error handling resources
- Flow and Action Error Handling Level 1: Retry and Action Error Evaluation - Workflow Automation CoE
- Flow and Action Error Handling Level 2: Flow Logic - Workflow Automation CoE
- Flow and Action Error Handling Level 3: Flow Error Handling - Workflow Automation CoE
- Flow and Action Error Handling Level 4: Good Practices and Summary - Workflow Automation CoE
General guidelines
Follow these general guidelines to achieve the benefits offered by flow error handling.
- Avoid adding error handling items to the main section of the flow
- A flow normally stops running when an action or subflow returns an error in the main section. A stopped flow cannot run any actions or subflows past the point where it returned an error. Adding error handling actions and subflows to the Error Handler section ensures they run them when there is an error.
- Capture Error Status information
- The Error Status object contains information about the action that produced an error. You can use this information to identify the cause of the error as well as record data that may need correction.
- Suppress subflow error messages
- You can enable the Error Handler for a subflow to prevent its errors from cascading to a parent flow. Leaving the subflow Error Handler section empty ensures that it always generates the Completed (error caught) state.
- Use subflows to avoid the 10-item limit
- Rather than force your error-handling-process to fit within a 10-item limit, call subflows, which can contain many more items. You can also use the subflow outputs to trigger automation in other flows.
- Use subflows to take corrective actions
- Rather than recreate the same sequence of actions in multiple flows, create reusable subflows to correct errors to your record data. When a flow error leaves your record data in an undesired state, use subflows to correct these records. You can use the error handler to identify such record data as a subflow output.