function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Irene SlessIrene Sless 

Flow trigger error handling

Being new to Flows I would like to know how to handle an error in a Flow Trigger. I have a Workflow rule set up which triggers a Flow Trigger, passing the Opportunity record to the Flow Trigger. In this Flow Trigger I loop through Opp Team Members and update a flag, then update these and adding a new entry. What I need to capture however is if no record is found and the Lookup User step to find the new person to add to the OTMs returns a null value. 

I get the error email:
Encountered unhandled fault when running process Update_Opp_TM/301O00000004Ltt exception by user/organization: 00DO0000000VuvS/{4} Source organization: 00D90000000tgIp (null) UPSERT --- UPSERT FAILED ---  ERRORS :  (REQUIRED_FIELD_MISSING) Required fields are missing: [UserId] ---  for SFDC record with ID : null,
caused by element : FlowRecordCreate.Create_FollowUp_OTM
caused by: UPSERT --- UPSERT FAILED ---  ERRORS :  (REQUIRED_FIELD_MISSING) Required fields are missing: [UserId] ---  for SFDC record with ID : null, 

This is my Flow Trigger:
User-added image
Before it does the Record Create I need to handle the error - it just needs to ignore the error and stop the flow. 
Andrew Brown 16Andrew Brown 16
Unfortunately (and happy to be corrected here), you can't 'handle' this kind of error unless you know beforehand exactly what conditions cause the error in the first place.  In this case, since you know that this is being triggered by your fast lookup returning no records, a workaround could be checking 'Assign null to the variable if no records are found." and then placing a decision just before the record create element to ensure that the sObject variable isn't null.
Irene SlessIrene Sless
Thanks Andrew
What I resorted to doing is catching the 'null' before going into the Flow, and also tried what you suggested - what I was wondering though, is what does one do with the 'No' side of the decision? 'Yes' goes in and does the processing of course, but there isn't an 'end' function one can use.
Andrew Brown 16Andrew Brown 16
You're not required to terminate every single option in the decision tree;  any unterminated conditions (such as 'No' in your case) will just cause the flow to halt/exit at that point as there's nothing more it can do.  Probably not the most elegant, but it works fine.