Flow Designer custom actions can report their own failures, and flows can react to them. Error evaluation lets an action return a custom status code and message when a specific condition appears. A flow’s Error Handler runs recovery steps when an error reaches it, and the Log action and action logs record what happened.
Two layers of error handling, kept separate
A failure starts inside the action, when a step cannot finish, or around it, when later work is affected. Keep the action responsible for describing what went wrong, and the flow responsible for deciding what happens next.
How a custom action reports its own status
Each action returns an Action Status object with a code and a message. That value comes from the first error condition that matches or, if none matches, from the Step Status of the last step run. The Step Status code is 1 when a step produces an error and 0 when it runs successfully, for reasons such as missing mandatory input data or output that arrives in an unexpected data type. You cannot change that code or the step message. Custom codes and messages come from the error conditions you define.
What the continue option changes
Each step has an “If this step fails” setting. It tells the action either to move to the next step or to jump to error evaluation. It does not change the Step Status, so a failed step still reports a code of 1 even when the action keeps going. That suits an optional step, such as a note nothing downstream depends on. It is a poor fit for a step whose output a later step needs, because that later step cannot succeed without the data.
Error conditions and the order they are checked
Error evaluation runs from top to bottom. Each error condition behaves like an else-if branch, so no more than one can be true at a time. The first match sets the Action Status and evaluation stops. A broad condition placed above a specific one catches the failure first, so put narrow conditions first.
Give each condition a label that says what it detects. Condition details stay hidden until someone opens them, so the label is what a designer sees while scanning the list. “Input record missing” tells the next person far more than “Condition 2”.
| Component | What it holds | Where it is set |
|---|---|---|
| Step Status | Code 1 or 0 and a message from the step | Produced by each step, not editable |
| Error condition | A label, a condition builder and the Don’t treat as error option | Error Evaluation section |
| Action Status Code | An integer you choose | Error condition |
| Action Status Message | A string you choose | Error condition |
| Action Status | The code and message the calling flow reads | Returned by the action |
Building an error condition step by step
Adding error conditions needs the flow_designer, action_designer or admin role. The sequence is the same for each custom action:
- Open Flow Designer, select the Actions tab and open the custom action.
- From the Action Outline, select Error Evaluation.
- Select Add error condition. Workflow Studio adds an If block for each one.
- Enter a descriptive label in the If field.
- Build the match in the condition builder: an action data pill, an operator and a matching value.
- Decide with Don’t treat as error whether the flow should read this match as an error or a success.
- Enter the Action Status Code and Action Status Message the flow will read.
- Order the conditions from narrowest to broadest.
- Select Save, then test with inputs that should trigger each condition.
Keep the list to 10 conditions or fewer, since each one is evaluated on each run. If you approach that number, consider splitting the action in two.
Writing the Log action
The Log action writes a message to the flow log table, sys_flow_log. It is a core action that users with the flow_designer or admin role can add. Each entry has a level of Error, Warn or Info, plus a message. Typed log text is limited to 255 characters in the design environment. A data pill can hold a longer value, and a script can call the GlideSystem log method with a message and a source.
Content matters more than length. A line that says “failed” tells you little the next morning, while a line carrying the record identifier and the failing step’s name points straight at the fault. Take those values from data pills produced by earlier steps. For more fixes when a flow misbehaves, see the practical troubleshooting guide for Flow Designer.
Adding an error handler to a flow
A user with the flow_designer or admin role opens the flow and enables the ERROR HANDLER switch. Workflow Studio adds an error handler section and matching entries in the Data pane. The section accepts up to 10 items: actions, flow logic options or subflows, counted together.
| Flow state | What it means | Where to see it |
|---|---|---|
| Completed (error caught) | The flow met an error and ran the handler items. It appears even when the handler is empty. | Flow execution details. Flow context records show Complete. |
| Completed (error skipped) | A custom action continued past a step failure and passed this state to the parent flow. | Flow execution details. Flow context records show Complete. |
| Error | The error was not caught. This happens when the handler is switched off, or when a handler item fails. | Flow execution details and flow context records |
When an error occurs in a flow with an active handler, the flow stops its remaining actions and logic and runs the handler section. If the handler items finish, the flow ends in Completed (error caught). If a handler item fails, it ends in Error.
The handler cannot resume the flow from the failing step or rerun the items that produced the error, so plan it around recording, notifying and correcting. A try block in the flow logic can keep a flow running after an error inside that block. For how the try block and other flow logic blocks are set up, see the guide to Workflow Studio flow logic control blocks.
A flow normally stops when an action or subflow returns an error in its main section, so error handling belongs in the handler section. Inside it, use the Error Status object, which holds the code and message of the error the flow caught.
Using subflows for recovery
A subflow extends the handler past its ten-item limit, and the parent calls it as one item. When a failure leaves record data in an undesired state, a reusable corrective subflow can restore it. The handler can pass out the identifiers of the affected records as subflow output, so the correction targets the right rows.
Suppression is useful and risky. Enable the Error Handler on a subflow and leave its section empty, and the subflow ends in Completed (error caught) instead of Error, so its failure does not cascade into the parent. The parent carries on, which also makes the failure easy to miss. If you suppress a subflow’s errors, add a Log action at the point of failure and check the action logs for its entries.
Testing error handling before you rely on it
Test with a deliberate fault. Create a throwaway action named “Throw an error” with a mandatory Integer input labelled Error Code, and a script step whose input variable is named code in lower case. The script throws a custom message when the code equals 1, on line 3. Run it with Error Code set to 1 and check that the Action Status shows the error on line 3. Publish it, add it to a test flow’s main body, and confirm the flow ends in Completed (error caught). Then remove the throwaway action, since a forgotten test step can reach real users. Other slips that catch teams out are covered in common Flow Designer mistakes and how to avoid them. Test on a non-production instance, because testing can change records. A broader sign-off list is in the Flow Designer testing and acceptance checklist.
Client callable actions
By default, a flow, subflow or action is called through the FlowAPI from a server script. Making one callable from a client script needs the security_admin role, and it may expose protected data or skip validation that a server-side call would apply. Create an access control of type client_callable_flow_object with operation execute and Admin overrides selected, tied to a role such as flow_api_access. Then open the flow, choose Manage security from More actions, select Callable by Client API, add the ACL and select Update. For the broader access model behind these roles, see Flow Designer security and access design.
Frequently asked questions
Does an error in a custom action stop the flow?
It depends on where the error lands. In the main section, a flow normally stops. Inside the error handler, the handler items run after the error is caught.
Can an error handler retry the step that failed?
No. A flow error handler cannot rerun the items that produced an error, and it cannot resume from the failing step. Use it to record the failure, notify someone, or run a corrective subflow. If the work needs another attempt, design the corrective subflow to bring the data back to a state the main work can run from.
What is the difference between Completed (error caught) and Completed (error skipped)?
Completed (error caught) means the flow met an error and ran its handler section. Completed (error skipped) means a custom action continued past a step failure and passed that state up to the parent flow. Both appear in the flow execution details.
Where do I look to see what an action did?
Start with the flow execution details for the run, then the Log action entries. For a view across the instance, use the action logs under Monitor in the Automation Center workspace.
For the wider design of flows, see the Flow Designer guides, and for what an action is before you add error handling to one, see the concept of an action in Flow Designer.