![Visual Flow Error Handling Utility Flows Visual Flow Error Handling Utility Flows](https://explorationsintosalesforce.wordpress.com/wp-content/uploads/2017/10/high-dive.jpg?w=150)
When I start a new project I often want to skip over the preparation stage and dive right into the deep end. For me that’s where the fun is! Along those same lines I have been known to drag my feet with finishing a project, but that’s a story for another time.
So ignoring setting up all the stuff needed to handle errors and immediately dig into the heart of the project often applies to me when I’m writing a new Flow.
And that’s exactly what happened again yesterday. So I asked myself, “Self, how can you make this easier?” (or something like that)
Here is what I came up with: two utility flows
- One to retrieve the bits and pieces needed for error reporting (and some other stuff)
- One to do the error reporting.
Two Utility Flows to Handle All Errors
- Error Handler Items
- Error Handler
The Error Handler Items Flow
Variables:
This flow does two things:
- Fetches and returns an email collection of Users who have been designated to receive error messages
- I’ve added a custom Boolean field to the User object, “Is Flow Error Recipient,” and have set it to True for Users who should receive error messages
- If there are no Users with this field set to True, the Users assigned to the System Administrator profile will receive the error messages
- This collection is necessary in the Error Handler Flow if that Flow is to send an email
- Returns the name of the User who launched the Flow
Of course if you wanted to make other items available to your calling Flow you could certainly do so. This could be a handy-dandy utility flow for fetching all sorts of things that you may need on a regular basis.
The Error Handler Flow
Variables:
This flow does also does two things:
- It constructs an email Subject and Body (that’s what the Text Templates do)
- It sends an email to the addresses in the
What is Gained?
At first blush this solution looks pretty much like the same amount of work as my prior solution where I used a utility flow to fetch the collection of email addresses and a Send Email element to report the error.
And certainly the number of elements I’m dragging into the Cloud Flow Designer is the same.
Where it saves time and attention is in these areas:
- The email Subject and Body are generated by the Error Handler flow so I don’t have to create formulas or text elements in each flow to do this
- If I want to change how the generated email looks I have only one place I need to go (as opposed to every single Flow where I have a Send Email element)
- This is huge for me as I’m all over the page here – having a single place where these items are structured will make for more consistent error reporting
- If I want to display the User’s name in the Flow, Error Handler Items exposes that information so I don’t have to create a function to get it
- If I want the way a User’s name displays to change I have only one Flow to update to make that happen across all Flows
- If I want to use other items on a regular basis I can use the Error Handler Items Flow to expose them
As my knowledge of Visual Flow has expanded I have revamped my error handling a couple times and I can honestly say that just the second bullet point alone is well worth the trouble of revamping it again. So that is my task for today: revisit all the Flows where errors need to be handled and install this method. For me it’s a small price to pay to be able to quickly update my error reporting down the road.
Cheers!