If your Flow includes a DML element such as Create, Update or Delete records, or a Submit for Approval core action, then there is a possibility that it might fail. For example, a create or update may fail if it does not pass the validation rule. And when the flow fails, Salesforce displays a standard message in red text that reads “An unhandled fault has occurred in this flow”. But with an error message like this, users will have no clue of what happened and if they did anything wrong.
A better option is to use something called ‘Fault’ path in Flow. Fault Path is also called Fault Connector or Fault Line. With Fault path, you can display a more meaningful message and guide users on what to do. To create a fault path, create a screen element with useful message and connect it to the DML element.
Customize the Error Message
For screen element you can use ‘Display Text’ or ‘Display Image’ components to make the error message visually appealing, pun-intended and in-context. For e.g. you can add an emoji with some stylized text to inform users of the error that happened.
Taking Error Handling to Next Level
With Fault path, you are not restricted to just displaying a custom error message. You can also add other components of Flow such as
- Assignment Element – To capture some information in a variable
- Text Template Resource – To draft a template with variable values to be used in email
- Send Email Core Action – Use the values from variable to send an email with error details to system administrator
- Create Records Element – to create a Case and assign it to your IT department
Error handling in Salesforce Flow seems like an interesting feature with multitude of possibilities. In this short guide we will be building on the Flow that we configured in the Step By Step Guide to creating Screen Flow in Salesforce. If you haven’t looked at the screen flow guide, I will recommend that you go through that post first, configure the Flow and then come back here to continue with this guide. In this guide you will learn how to:
- Add a Static Resource in Salesforce
- Add Fault Path to Flow Element
- Test Custom Flow Error Message
and it won’t take more than 10-15 minutes of your time
Want to download this PDF or watch a training video? We are now offering a complete course on Salesforce Flows called “Mastering Salesforce Flows”. To find out more about the course and watch a free preview, please click here.
References & Useful URLs:
- Customize What Happens When a Flow Fails – Help Article (5 mins) – https://help.salesforce.com/articleView?id=sf.flow_build_logic_fault.htm&type=5
- What Happens When a Flow Fails? – Help Article (3 mins) – https://help.salesforce.com/articleView?id=sf.flow_build_logic_fault_default.htm&type=5
- Configure Every Fault Path to Send You an Email (Best Practice) – Help Article (5 mins) – Configure Every Fault Path to Send You an Email (Best Practice) (salesforce.com)
- Customize the Error Message for Running Flow Users (Best Practice) – Help Article (3 mins) – Customize the Error Message for Running Flow Users (Best Practice) (salesforce.com)
- Other Examples of Error Handling in Flows – Help Article (5 mins) – Other Examples of Error Handling in Flows (salesforce.com)