Fault Path in a Flow
When a fault occurs in a Flow, we will use a fault path so our end user does not get this ugly system-generated error.
If they do, it means as a flow builder, we have not done our job properly.
The fault can occur for many reasons, we may be missing a required field, the record may not exist, or the user may not have access to update/delete the record.
Fortunately, by creating a Fault Path you can handle it better by displaying a more helpful message to the user and emailing the Salesforce Administrator with the details.
For Screen Flows, we will do this in a subflow that can be reused from any screen flow. If it’s an after-save Record-Triggered flow we can also use a subflow – we just can’t display a message.
How to Implement Fault Path in a Flow (for screen flows)
Use these detailed instructions to build the flow:
Note: Because the screen flows are the only type of flow that can display messages to end users, this subflow is limited to being used as the fault path for screen flows only. You can’t use this one for record-triggered flows.
Flow overview:
Create a new screen flow.
Create a variable to pass the fault into the flow. The data type will be text and it must be set to Available for input.
Next, create a new Text Template that will be used for displaying the fault_message to the end user:
Create a second Text Template to be used as an email message body. That will be sent to the Salesforce Admin or a support mailbox:
Add a Screen element and insert a Display Text component. This will display the error to the end user (using the text template):
Create an email action to send the message to the admin. It could also go to another user or a mailbox for all errors.
… the remainder of the page configuration:
Save the flow:
You could also (or instead of sending the email) send a message via chatter to a specific user or group. You could also use Slack to send the messsage. Another alternative is to create a new Case for the service desk to deal with the problem. Anything you can do that will make sure the problem is followed up, resolved and prevented from occuring again.
Using the Subflow
Now, in any screen flow, you can call this flow to handle errors for you.
In this example, we are creating Lead Records. If we get an error we call the Fault Path-Screen subflow and pass the fault_message into the flow.
We click on the Create Records element (1) and select Add Fault Path (2)
Next, click in the small circle above the end element to add the subflow:
Select a Subflow Element to add here and configure it as follows. Add a Label (1) then select the subflow (2) and Set Input Values. Choose the global variable Running Flow Interview and under there select the FaultMessage (3).
Now your fault path is complete. Any fault that occurs on this Create Records will call the subflow.
The advantage of using a subflow is that we can call it from every screen flow we create and all we have to pass into it is the fault_message. If we decide we want to use Slack or Chatter to deliver the message to another support person, or even create a case from the fault, we can just make a single change in the subflow and all flows using it will now have the new functionality.