How to solve Salesforce Flow errors
Flow is the greatest automation tool in an Admin's appliance. You can easily implement things into the system and make things happen automatically without any input/interference from your users. You can also create Screen Flows to display messages for your users, and immerse them into a Lightning Page or make them available and work from point-click Buttons. However, Salesforce flows are sometimes scary, there is plenty of room for errors and faults…
What is an Unhandled Fault?
This error is thrown when we are trying to hit governor limits of Salesforce. In other words, going against something Salesforce is expecting.
How to Construct Flow Error Messages
Sometimes working with flows, we get a very cryptic error message “unhandled fault has occurred”, and the end-user will have no idea what went wrong. So, what’s the matter with the field in this record? What is the best way to handle this? There are a number of techniques to handle it.
1. Using Decisions to Avoid Flow Errors
To bypass hitting a ‘fault’ altogether, you can use a Decision element to create and then check for specific criteria before running and looping the user back around. You can construct custom Screens to explain an error. For example, if you want to let your users know that the Account they’re working on has zero Contacts, then you would need to create a Screen after the element Get Contacts which can explain it, and create a criterion using a Decision element that decides when to display the error.
2. Constructing a Custom Error Message for Users and Admins
Salesforce Flows should be built using best practices to avoid errors. We should always use “Fault” connectors to check when and where a flow fails. This will help you understand and spot errors that need to be rectified before becoming a headache to your users. Let’s see an example:
In the picture above, the flow was used to create new leads. The main problem was that it was not tested properly before moving to production. There was a field that was required while creating a lead named “Lead Source”. And provided custom error messages weren’t set up, it will only show as “Not Working”. So, you might be wondering how to create a ‘Fault’ line? Simply drag the node to the Screen you want displayed if an error occurs, and the red Fault path will be created.
With the help of a custom Error Screen, your users will be able to see a bit more information: they will be able to identify the issue and understand it is related to the “Lead Source” field missing. You will also receive an email for the same error message (with additional information such as their input values, the date/time the Flow was run, and the user who ran it).
3. Flow Errors Caused by Inactive Users
This error occurs when a user is inactive, as he or she has left the organization. For example: if a user is assigned to a flow to be run by a particular user who is inactive, you may get an error such as “interview that has been paused”.
The best solution to resolve this issue is, before deactivating the users, first freeze the user and assign all its active flows to a different active user. Only then deactivate the frozen user.
4. Change Who Receives Flow Error Emails
If you want to receive emails whenever the flow fails, no worries, Salesforce provides the Process Automation Settings in Setup that shows you who should be receiving the Flow error emails. You can select between two options whether it will be the ‘User Who Last Modified the Process or Flow’, or ‘Apex Exception Email Recipients’ (this is a list of users specified on the Apex Exception Email page).
5. Ignoring Salesforce Flow Errors
You can also ignore a few errors by dragging the Fault line to the same place as the success line. Generally, this is not suggested, and should only be done in certain opportunity circumstances, such as securing a Contact is part of a specific Campaign.
An error will be thrown whenever the user is trying to add a contact campaign but he can continue with the rest of the flow.
6. Apply Salesforce Cases to Manage Flow Errors
Now Salesforce not only allows sending an email whenever a flow fails but it also creates cases whenever any flow fails. This will help your users to build trust between them and Salesforce that will also help them to learn that everything is noticed and the system is evolving and improving and that they will see the same error repeatedly.
7. Accessing List of Failed Flow Interviews in Setup:
Now we can see “All Failed Flow Interviews”, by following the steps below:
Setup > Quick Find Bar > All Failed Flow Interviews List View.
8. Object/Field-Level Security
Flows can be run either in user mode or system mode. Whenever the flow runs in system mode, it has permissions to access and modify all data while if it runs in the user mode, the object and field restrictions of the running user will be applied. Let’s say, for example, that the flow needs to update the Status field on the Lead record but your user doesn’t have access to edit that field. Then, if the flow is running in user mode, an error will be returned.
9. Too Many SOQL Queries:
SOQL (Salesforce Object Query Language) allows you to search for information within Salesforce records. In flows, SOQL is used to create and update records. So, there is a limit of 100 SOQL queries. If the flow is running a lot of SOQL queries, you may hit governor limits and get a “too many SOQL queries” error.
Tip: Add a Pause element (you can resume the flow immediately) before the Update Records element that is throwing the error. The query limit will be reset.
10. Where did the flow fail?
First, we need to use an assignment element to record where exactly the flow fails and what went wrong.
… And Time to relax:
We can use fault connectors to handle errors in our flows, to improve user experience and help deliver the information that Admins need in order to understand problems with Flows quickly.
Salesforce Flows are powerful. They allow to configure their system with custom automated logic and Admins to provide easy-to-use screens for your users, but there’s no uncertainty they’ll fail from time to time. The perfect solution is to anticipate this and build a correct Flow design with Fault Handling, so you can manage it better.