Adding a Step Outcome for ExceptionsLast Updated: 05/03/2018 Introduced in Version: 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 work space. It can be found in the the category Integrations > All Integrations > Internal Services > AccountService. Click Add to place component into the work space.
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. We can Pick an account or Define the parameters of a new account. In the Define Data section, we can see two fields that are required: EmailAddress and EntityName. We’ll fill in the EmailAddress with our invalid value and the EntityName with “QA,” for this example.
We set the memberOf and password inputs to ignore and, finally, we save our changes by clicking the Define button. 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.