Handling Flow Faults Elegantly

Two of the biggest mistakes that can happen while implementing any automation can be:
  1. Exceptions and Errors are not handled at all resulting in a bad user experience OR
  2. Always capturing the Exceptions but not taking action after that may result in silently killing them and giving users an impression that everything worked as expected but actually, it did not do what was expected from that automation.
And same goes for Flows. Flows comes with a very powerful way of handling exceptions and taking corrective actions. Logging all these exceptions in a customer object can be a very helpful in taking corrective actions and avoid having these kinds of issues in the future.

Custom Object (Fault Log)

Create a Custom Object to log all these exceptions generated from Flows. Create at least the below fields to track the issue details:
  1. Name (Auto Number)
  2. Flow Name (Text) – To Capture the name of the flow from where the exception was raised
  3. Record Id (Text) – If raised by a Record Triggered Flow, this can be used to capture the record Id from which this exception was originated
  4. Details (Long Text Area) – To capture the Fault Exception details.

Sub Flow

Create a Sub Flow that creates a record in the Fault Log custom object and can be called in the fault handler from various different flows: Create a new “Autolaunched Flow (Trigger)” to be used as a Sub Flow within other flows. Name it “Fault Handler”. Create three new Flow variables:
    1. Details – Text – Available for Input
    2. FlowName – Text – Available for Input
    3. RecordId – Text – Available for Input
Add a node to create a new record of type Flow Log and use the values available from the three variables above:

Here is the sub-flow that creates a new record in Flow Log custom object:

Screenshot 2023-05-14 at 9.36.00 AM

Using Fault Handler Sub Flow

Now that we have all the Ammo ready, lets see how we can use this. In any given flows where you can capture faults.

Click on a node to add a Fault Path, usually they are the GET and DML nodes in the flow.

Screenshot 2023-05-14 at 10.00.25 AM

There are multiple options to select from while adding a Fault Path, select Sub Flow and select the Sub Flow named “Fault Handler” that we have just created and set these values

Details – Set the Flow > Fault Message in this field.

Flow Name – This is the current parent flow name from where the exception has been triggered.

Record Id – Id the record that triggered the flow.

Finally, this is how the Fault Handler looks like after adding it to a node. The details will be captured in the custom object if there is an exception.

Please Note that adding this fault handler can be an addition to how you want to handle the complete Flow Path. You can still add additional actions to the flow path along with this Fault Handler Sub Flow.

Finally

Now that we have the issues logged in the custom object, here is how you can use them:

  • Create a formula field on “Flow Log” custom object to categorize the records.
  • “Flow Log” records can be assigned automatically to the relevant team to work upon.
  • Admins can create reports and analyze them to find a permanent solution to these issues or handle them in a better way in the flows.