Adding a Step Outcome for ExceptionsLast Updated: 12/03/2015 Introduced in Verision: 2.0
Even under the best conditions, inputs can be unreliable. To handle missing or invalid data without crashing, steps need paths to account for errors or exceptions. We can add these outcome paths by selecting the Add Outcome for Exception checkbox in the Properties panel and mapping them to steps which can display or otherwise manage errors.
In the example, we will attempt to add an account that already exists in the system using the Add New Account component. When the flow cannot perform this invalid action, rather than stopping, the flow directs to the On Exception path and proceeds to the End Step.
Begin in the Flow Designer’s startup window by placing an Add New Account component in the workspace. It can be found in the under the category Integrations > All Integrations > Internal Services > AccountService. Click Add to place component into the workspace.
Rather than create additional steps to handle our exception, connect the paths On Exception and Done to the end step, and prevent an exception from occurring in another way.
Exception paths are a necessary part of any flow, but we don’t want our flow to follow them except in extreme cases. However, we do want to test our exception path, so we will temporarily remap our inputs to an invalid state. In our application’s database, the user account associated with “email@example.com” already exists. We will remap our inputs so that the next time Add New Account runs, it will try to add a user with the same email address, which is an invalid condition.
Clicking this button reveals all of the properties for the account object input. Right away, we can see two fields that are required, but empty EmailAddress and EntityName. We’ll fill in EmailAddress with our invalid value
. . .and EntityName with “QA.”
Finally we save our changes and click OK to exit the Mapping Editor.
Now, when we run our flow in the debugger, we can see that the Add New Account step results in an error, causing our flow to follow the On Exception outcome path. If we want, we can place a variety of display or notification steps to handle this error.