Riding the Fault Line – How to Handle Flow Errors in Salesforce

Road Closed Signs, LA

 

The Flow Builder is a powerful tool for Admins; it allows us to build user journeys that look great and execute complex business logic at Lightning speed.

When you use flows in your org, the chances are thereโ€™s going to be bumps along the road and your flows are not always going to do what they were designed to do.

There are 100s of different ways you can make your flow throw an error, so you can get creative! From trying to create records without required fields, to breaking flow limits.

In this blog, we wonโ€™t cover how to avoid the errors in the first place. We are going to look at how we can handle those Flow errors in the best way possible.

 

Dear User – Computer Says No

Most users of flow will be familiar with this picture:

An Unhandled Fault Error Message

 

It isnโ€™t a very pretty error message and it still makes my blood run cold. I used to imagine what the end-user must think when they see this message:

Have I broken something? Is Salesforce broken? Did any actions take place?

At best itโ€™s inconvenient and at worst it makes you as an Admin look unprofessional and erodes confidence in the system.

 

The Fault Connector

If I expected most readers to have seen the โ€˜Unhandled Faultโ€™ message, I wonder how many of you have seen โ€˜Fault Connectorsโ€™ which Salesforce provides to handle Flow errors?

Fault Connector

I work on many Salesforce Orgs and I rarely see these used. They are recommended as best practice and using them can make flows failing a lot less stressful.

You can use the fault connector from any of the โ€˜dataโ€™ elements (the pink ones), 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.

Creating a Fault Connector gif

 

 

Next Stop on the Fault Line

We now know how to create a fault connection, but what do we attach it to? Below is a simple screen flow which lets users create a Contact and Account at the same time. We will use this to demonstrate some of the best elements to use after things have gone wrong.

Full View of the Demo Flow

 

 

Where did the flow fail?

First things first – use an assignment element to record exactly where the flow went wrong. I usually assign a value to a text variable called โ€˜Error locationโ€™. Spoiler alertโ€ฆ weโ€™ll be using this later.

Assigning a value to the ErrorLocation Variable

 

Nothing to see here

Never see that awful red โ€˜Unhandled Faultโ€™ message in your screen flows again! Use a Screen element and Display Text to communicate with the user. You can even add images and merge fields such as {!$Flow.FaultMessage}. With this fault message, the user might even be able to see what is wrong themselves.

Note: This can only be done in screen flows. Flows which are auto-launched from a Process Builder, for example, will show an error message on the screen where you are triggering the flow.

Custom Error Message Screen Component

 

Better email notifications for Admins (and Users)

The standard error email received when a flow breaks can be quite difficult to decipher. So why donโ€™t we make our own?

We can curate a personalised email alert to Admins of the org to let them know that the Flow has gone wrong, and we can even use the {!ErrorLocation} variable from before to tell them exactly where itโ€™s fallen over.

I create a โ€˜Text Templateโ€™ resource and use that for the body of a โ€˜Send Emailโ€™ core action. You could even send an email to the running user to put their mind at rest too.

Text Template with Merge Fields for Email

 

Create a case

If your IT team uses Salesforce Cases to manage requests, then why not cut out the intermediaries and create it straight away with a Create Record element? You can use the merge fields we have seen along the way to populate the Subject, Description and other fields.

 

Time to Relax

Using fault connectors to handle errorsย in your flows will improve your usersโ€™ experience and help deliver the informationย that Adminsย need toย understand problems with Flowsย quickly. That new screen flow error message looks so nice… I secretly hope I see it again soon!

 

Further Reading

Now you know how to handle Flow errors,ย  it might be worth bundling up the actions in a subflow so you can call them again and again. This free AppExchange product from Salesforce Labs gives you a big head start on doing this by giving you a subflow with some email actions which you can call with your fault connector.

For the full detail on Flow errors, see theย Salesforce Documentation

Work with Desynit

Looking for exceptional, professional Salesforce support?

Our independent tech team has been servicing enterprise clients for over 15 years from our HQ in Bristol, UK. Let’s see how we can work together and get the most out of your Salesforce implementation.