Fault Handling in Salesforce Flows

Build
Nicholas Scallorn
Nicholas Scallorn
Salesforce Innovator
Share article to

Utilizing Salesforce Flows to implement business logic can be challenging, especially when unhandled faults occur. Unfortunately, there’s limited guidance on how to address these issues and at times the process of understanding new tools can feel overwhelming. But you’re not alone—and by following a few best practices, you can navigate these challenges with confidence.

In this article, we’ll cover how to create effective error handling when implementing any business logic in your Salesforce org. We’ll also help you to streamline your User Experience and clearly separate concerns regarding which Flow elements need your attention.

Flow fault examples

A few examples of faults that can happen in a Flow are:

  • A Flow attempts to edit or create records / fields the running user does not have access to.
  • A Flow tries to create a record without a required field.
  • A Flow tries to send an email to an invalid email address.
  • A Flow triggers a validation rule.

Handling these faults is necessary since any one of these scenarios can happen multiple times a day in an org.

If you’ve used Apex, you’ve likely seen how this is handled in Triggers. The closest analog in procedural programming would be a try / catch block with a system debug statement. For example, if you have a try block that fails and an except block that executes a System.debug statement, this statement can print a custom message. This usually looks like this:

Catch(DmlException e) {
     System.debug (“The following error occurred: “ + e.getmessage());
}

However, handling these errors in Salesforce Flow is very simple with options that can be leveraged for a better user experience, such as: Custom Errors, Emails, Record creation, locking Records, and creating Chatter Posts.

How to create a fault path in a Flow

Creating a fault path in Flow is as simple as creating any other element. Simply select the element that is likely to cause an error and select “Add Fault Path”. This creates a red dashed Fault line.

Now we can use this fault path to create custom scenarios to handle a fault for a particular element in the Flow.

Diagram displaying an example of how to handle a fault in a Salesforce Flow

Creating custom errors for your Fault Path

Creating a custom error is a great way to enhance the user experience and cut down on unnecessary communication.

For example, most end users are not aware that Admins are receiving notifications when an error occurs. A custom error message that gives the user more insight into the issue and notifies them that their admin has received a message would cut down on the amount of communication from end users. This can be added to one or more of your Flow elements.

If the error occurred while attempting to update a particular record, the variables from that record can also be included in the custom error message.

Creating Email Alerts

Automated Flow error emails are typically difficult to read, and you can cut down on the time you spend reading through them with a Custom Email Alert. Like Custom Errors, you can customize these Email Alerts to your liking. They can include Flow errors, the running User, and the Element that caused the error.

Email Alerts are also a great way to notify non-admin users when a fault occurs. For example, if a manager wants to be notified via Email Alert when a user creates a record via Flow that triggers a Validation Rule, then that manager could be notified and intervene with additional hands-on training.

Other Actions when an error occurs

Like Email Alerts, other Actions can also be used outside of Fault Paths to create new records, generate Knowledge articles, lock records, send notifications, and post to Chatter.

For this Insight, creating a Case will be the most beneficial to cover. Simply use Actions to create the case and assign it to the Salesforce Administrator’s Queue. You can also reference variables from the generated case in a Custom Error screen for the end user to reference.

Custom error example in Salesforce

The User would then be presented with this message:
“It looks like you do not have access to this record.

We filed case {!caseNumber} for your Administrator to review.”

Triggering a Subflow when an error occurs

The most technical option would be to call a Subflow. This Subflow can perform all the above actions outside of the initial flow. You can reuse a Subflow in any of your Record-Triggered Flows to avoid having to individually recreate any of these custom solutions for your errors.

Anticipating errors with better Flow practices

With the vast amount of information available around handling the errors in the Flow, you may be wondering how to avoid them altogether. Using a decision element is a great way to accomplish this.

As highlighted earlier, a potential cause for a Flow fault could be the Flow attempting to send an email to an invalid or NULL email address. You can add a decision element after the trigger to reference the Email field on the Contact and check if it is NULL. If it is, you can End the flow and avoid the error. If it is not NULL, you can continue with Flow and send automated email alerts.

Conclusion

There are many ways to customize your Fault Path and handle errors in your Salesforce Flows, and Salesforce has placed all the necessary tools to create a better process at your fingertips.

Whether you decide to stop at custom messages or expand your solution to add notifications, email alerts, record creation, or Subflows; all of these options are better practice than leaving the fault unhandled. For a free consultation on your Salesforce org, please drop us a line.

Tips you should know:

  • Salesforce is continuing to invest in declarative programming and there is a big push to provide similar tools to end users in Flow Builder that are typically present in Apex.
  • Salesforce is consistently making Flow updates regarding HTTP Callouts, Transform Elements, and other UI enhancements.
  • While updates are consistently being rolled out, some logic will still need to be implemented by Developers in Apex.
  • Salesforce has released their Flow Element: Custom Error documentation. This contains more information on how to handle Custom Errors and considerations when using them in your org.
  • While there are several Other Examples of Error Handling in Flows, each scenario will likely call for a unique solution.

About HomeTree Digital

HomeTree Digital is a full-service digital marketing agency for financial services. We incorporate design & creative elements to our work and specialize in email marketing, social media marketing, paid advertising, videography, web development, custom integrations, and automations. As a Salesforce Certified Partner, we can assist with the architecture, administration, or development of your CRM. If you are facing challenges in any of these areas, please reach out to us for assistance. Personalize your subscription to receive regular updates.

HomeTree is defined as a wise resourceful home that provides knowledge, instills inspiration, encourages creativity, and protects. While harmoniously connecting its residents through its branches and roots to the outer world. This accurately describes the approach we take when it comes to our clients. We believe in excellent customer service and prioritizing you. Our mission is to provide you with the know-how to succeed in a rapidly evolving digital world.


Nicholas Scallorn

About the author

Nicholas Scallorn is a Salesforce Innovator at HomeTree Digital who brings years of expertise and fresh ideas to both Salesforce and data solutions. With a proven ability to bridge the gap between business stakeholders and technical teams, Nicholas possesses a deep understanding of Salesforce, data analytics, data science, and data visualizations. His years of experience at organizations like SESAC Music Group (a Blackstone Portfolio Company) and his academic pursuits, including an MBA with a concentration in Data Analytics, have equipped him with this valuable skillset. Outside of work, Nick enjoys traveling with his family, playing the guitar, and restoring classic cars.

Continue reading...

Two beautiful business people working on laptop computers at conference room.
How to set up your Salesforce Org’s permissions through Permission Sets and Permission Set Groups to prepare...

Contact us

    Interested in working together? Please complete the form below and we will get back to you soon.

    This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.