back to blog
Unhandled Errors in Flow
March 08 2022 • 15 min read

BUSINESS SCENARIO

While creating a screen flow in Salesforce we connect different elements to meet the given requirement. We may overlook some possibilities where the error may occur and we do not know at which element the error has occurred.

We can use fault screens for certain elements and get the error displayed on the screen to know where the error occurred. Fault screens can be added to either data elements or action elements and a custom error message can be configured.

We can also add a screen to the decision element to display a screen when the decision outcome is something else than expected

This way fault connectors along with screen elements can help us handle the errors.

There are two ways to handle errors in screen flows: 

  1. Using Fault Connectors
  2. Using Decision Elements

USING FAULT CONNECTORS

WHAT ARE FAULT CONNECTORS?

While a connection determines the normal path of flow execution, a fault connector is executed at runtime only when its source element results in an error.

 HOW CAN THEY BE USED?

The fault connector can be used to connect from any of the ‘data’ elements , or the Action elements in the Flow toolbox. To create a fault connector, simply create a second connection from your element after creating your first connection. 

screenshot 71

When we use a fault line to show an error message it helps your users to know what specifically caused the error that will help to resolve the issue.

The following screen flow sends email to all Public Group Members with any details about deals or updates.

Creating  the screen flow involves the follow these steps:

  1. Add a Screen Element to Enter Message

  2. Use Get Records Element to get Public Group Members & their details

  3. Loop through Members to Collect User ID’s of Members

  4. Loop through User ID to get their Email Addresses

  5.  Use Action Element to Send Emails

    screenshot 72

    In the above flow, the Elements(Get Records, Action, Screen) still have one node they can be connected to.

    screenshot 73

    This node when dragged to another screen element adds a fault line to that element. When the line is dragged from Send Email Action Element to the Error Screen, it creates a fault line.

    screenshot 74

  6. Add Screen Elements for Success and Error Messages.

    screenshot 75

    screenshot 76

    screenshot 77

CUSTOMIZING ERRORS

When a flow fails, the user running the flow gets this error message

screenshot 78

The user running the flow does not know what went wrong when such messages are displayed. So when we use a Screen element and Display Text to Communicate with the user and display a Customized Error Message, the user might even be able to figure out what is the issue and where it went wrong.

After customizing our error message, the user will see something like this on their screen.

screenshot 79

We can also add an Email action after the error message is displayed to send emails to System Admins to notify them with the Error Message. 

screenshot 80

The Body of the Text Template can include more details than just the “Fault Message”

screenshot 81

USING DECISION ELEMENTS

Instead of hitting an error after the flow has run, you can use decision elements to check the criteria and use screen elements to display where exactly the error has occurred.

The example below shows a flow that is created to Send Notification to Public Group/Opportunity Team Members that a particular opportunity has been closed. 

You can learn more about it from this Blog.

In this example, we used 3 decision elements to check whether the collection ISNULL or not. Based on the decision 2 outcomes are generated. One when the Collection has values and another when the Collection is Empty.

The decision element here lets the user check specific criteria before proceeding and loop the user back around to gather other information.

screenshot 82

Now, instead of seeing an Error Message after the entire flow has run we can have various checkpoints in the form of decision elements to identify where the flow stopped running.

This screenshot shows the “Fault_1” & “Fault_3” screen from above example

screenshot 83

WRAPPING IT UP

Screen Flows gives you the ability to automate complex processes and even allows you to provide end-users with quick screens to input the data you need, but they end up less efficient when we overlook the errors. The best solution - build correct Fault Handling into the Flows design, so that it can be managed better when it occurs.

Leave a Comment

Your email address will not be published

© 2024 Digital Biz Tech