Sub topic 11
Diagnosing Common Flow Failures
This chapter assumes you can build a basic flow and have read the earlier chapters on the Flow Builder debugger, fault paths, debug logs, and governor limits. It gives you a repeatable way to go from a failure message to a cause and a fix.
A Diagnosis Routine
Most flow failures fall into a few groups. Work through the same steps each time.
- Read the error text. It names the element and usually the limit or the rule that failed.
- Find the failing interview. Use the flow error email, the fault path output, or the debug log.
- Reproduce it in the debugger with the same input values and the same running user.
- Change one thing and run again.
Governor Limit Errors
A message such as Too many SOQL queries: 101 or Too many DML statements: 151 means the whole transaction used more than its allowance. The flow may not be the only cause, because Apex triggers and other flows in the same transaction share the limits.
The usual flow-level cause is a Get Records, Create Records, Update Records, or Delete Records element inside a Loop. It works with one record and fails when 200 records arrive together.
The fix is to collect changes in a collection variable inside the loop, then run one DML element after the loop ends. If you need lookup data, run one Get Records before the loop and read from the collection.
Data and Validation Errors
Messages such as REQUIRED_FIELD_MISSING, FIELD_CUSTOM_VALIDATION_EXCEPTION, and STRING_TOO_LONG come from the data the flow writes, not from the flow engine. Check these points.
- The flow sets every required field on a Create Records element.
- Validation rules on the object pass for the values the flow assigns.
- Text values fit the field length, especially when you join several fields into one formula.
- Picklist values match an active value exactly.
A validation rule can fail only for some records. Debug with the values from the failing record, not with a convenient sample.
Null Values and Empty Results
If a Get Records element finds nothing, its output variable is empty. A later element that reads {!Get_Account.Name} then fails or silently writes a blank. Add a Decision after each Get Records and test whether the result is null before you use it.
In a fault-path message, include the identifying data so you can find the record later:
An error occurred in the flow: {!$Flow.FaultMessage}
Time: {!$Flow.CurrentDateTime}
Record Id: {!$Record.Id}$Record.Id applies only in record-triggered flows. In other flow types, pass the record ID in through an input variable.
Permission and Context Errors
A flow can behave differently depending on who or what starts it.
| Symptom | Likely cause | What to check |
|---|---|---|
| Works for you, fails for a user | The flow runs in user context and that user lacks field or object access | Debug with Run as another user, or change the run mode |
| Works in the debugger, differs in production | Debugger rolled back changes, or data differs | Turn off rollback in a sandbox, and compare data |
| `UNABLE_TO_LOCK_ROW` | Another transaction holds the record | Look for parallel flows, triggers, or integrations on the same record |
| Flow does not start | Entry conditions are not met, or the flow is inactive | Check the active version and the trigger conditions |
Recursion and Overlapping Automation
A record-triggered flow that updates its own object can cause the same flow to run again. Salesforce stops the chain at a depth limit and returns an error, but a loop that is bounded may still waste limits.
Reduce the risk in these ways.
- Set entry conditions so the flow runs only when a field changes (use "Only when a record is updated to meet the condition requirements").
- Use a before-save flow to change fields on the triggering record. It needs no extra DML.
- Keep one flow per object and trigger type where possible, and document the order.
A before-save flow cannot call actions or create related records, so move those parts to an after-save flow.
Confirming the Fix
After each change, run a bulk test with 200 records. A fix that passes for one record can still fail in bulk. Keep the failing case as a permanent test so the failure cannot return unnoticed.
Exercise
A record-triggered flow works when you edit one Opportunity but fails with "Too many SOQL queries: 101" during a data load of 200 records. What is the most likely cause, and how do you fix it?
Show answer
A Get Records element is probably inside a Loop, so it runs one query per record. Move the query before the loop, store the results in a collection, and read from that collection inside the loop. Use one DML element after the loop for any updates. Confirm the fix with a 200-record bulk test.