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:
- Using Fault Connectors
- 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.
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:
Add a Screen Element to Enter Message
Use Get Records Element to get Public Group Members & their details
Loop through Members to Collect User ID’s of Members
Loop through User ID to get their Email Addresses
Use Action Element to Send Emails
In the above flow, the Elements(Get Records, Action, Screen) still have one node they can be connected to.
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.
Add Screen Elements for Success and Error Messages.
When a flow fails, the user running the flow gets this error message
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.
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.
The Body of the Text Template can include more details than just the “Fault Message”
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.
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
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