Flow error handler
Summarize
Summary of Flow error handler
The Flow Error Handler in ServiceNow enables flows to detect and respond to errors automatically. By enabling this feature, flows can run specific actions and subflows to identify, log, notify, and correct issues as they occur, reducing manual troubleshooting and interventions.
Show less
Key Features
- Error Handler switch: Enables or disables error handling within a flow, revealing the Error Handler section when active.
- Error Handler section: A dedicated part of the flow where up to 10 items (actions, logic, or subflows) run when an error is caught, automating error resolution steps.
- Error Status object: Provides detailed error information through data pills including a code (indicating error presence) and a message describing the error.
- Error States: Includes states such as Completed (error caught), Completed (error skipped), and Error. These states help track flow execution outcomes related to errors, visible in flow execution details.
- Custom error codes: Custom actions can define specific error codes to better handle unique scenarios.
- Subflow error handling: Subflows can have their own error handlers to prevent errors from propagating to parent flows, ensuring smoother error management and reusability.
Practical Guidelines for ServiceNow Customers
- Use the Error Handler section: Place error-handling actions and subflows here, ensuring they run only when errors occur and do not disrupt the main flow sequence.
- Capture error details: Utilize the Error Status object to identify error causes and gather data for corrective actions.
- Work within the 10-item limit: To manage error handling workflows exceeding 10 steps, leverage subflows to organize and extend error-handling logic.
- Reuse subflows: Create reusable subflows for common corrective actions to maintain consistency and reduce duplication across multiple flows.
- Test error handling: Develop custom actions that intentionally throw errors to validate and improve your flow error handling setup.
- Continue flow execution selectively: Use Try flow logic to allow continuation after errors within a controlled block, complementing the Error Handler’s capabilities.
Expected Outcomes
By implementing flow error handling, ServiceNow customers can automate error detection and resolution, reduce manual troubleshooting efforts, and maintain data integrity by correcting records affected by errors. This leads to more reliable and maintainable automation workflows with clear error tracking and recovery paths.
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.