When the approval flow dies and the UI will not say why
Every Salesforce architect and developer has met the dreaded "Approval Process Error" notification. With an approval flow failing, the standard UI gives you almost nothing to work with. Apex hands you a clear stack trace. Flows often fail silently, or come back with a generic "An error occurred".
This is the order I work in when a broken approval process and the Flows hanging off it need fixing.
1. Debug logs in the right user context
Flows run in the context of the user who triggered the action, which is the thing most developers forget. If your approval process fires a Flow that updates a record, and the submitting user has no Field Level Security on that field, the Flow fails. Targeted debug logs catch it.
- Go to Setup > Debug Logs.
- Create a new trace flag for the user hitting the issue, or for yourself if you can reproduce it.
- Set the log level for Workflow to
FINESTand Apex Code toFINER. - Trigger the approval process again.
- Open the log and search for
FLOW_ELEMENT_ERRORorFLOW_INTERVIEW_FINISHED.
At those levels you can tell whether the failure happened at the record-update step or in a DML operation triggered by the approval outcome.
2. The Debug tool in Flow Builder
Since 2021 the Flow Builder Debug tool has been the first thing I reach for. Debugging an approval process with it is awkward, though, because the trigger is external: the Approval Process itself fires the Flow.
Build a test harness instead. If the Flow is triggered by a record update, say a status change to 'Pending Approval', do not trigger it through the UI. Use the Debug button in Flow Builder, choose 'Triggered by a Record', and point it at the record ID that is currently stuck. Then watch which decision element falls over. Approval logic gets tangled quickly, so check that every formula variable evaluates the way you expect during the debug run.
// Example: If a formula field used in a decision fails
// Check if your formula returns null or an unexpected data type
IF(ISBLANK({!$Record.Approver__c}), 'Default', {!$Record.Approver__c})
3. Process automation settings
Plenty of these failures come from the environment rather than the Flow logic. If the error mentions "Insufficient Privileges" or "Record Lock", check the usual suspects.
The user needs the 'Run Flows' permission. Salesforce locks records automatically during an approval process, so a Flow that tries to update a locked record without running in System Context will crash. And in the Flow's Advanced settings, System Context Without Sharing—Access All Data is what you want when the user triggering the approval has no edit access to the underlying records.
4. Monitoring failures from Apex
If the Flow is mission critical, stop relying on email notifications alone. Wrap the logic in try-catch blocks inside an invocable method, and push the error details to a custom Exception Log object when it fails.
public class FlowErrorHandler {
@InvocableMethod(label='Log Flow Error')
public static void logError(List<String> errorMessages) {
List<Error_Log__c> logs = new List<Error_Log__c>();
for(String msg : errorMessages) {
logs.add(new Error_Log__c(Message__c = msg, Timestamp__c = DateTime.now()));
}
insert logs;
}
}
5. Common root causes
Before you go deeper, run down this list.
- Did the approval process trigger an update that left a required field blank?
- Did the record update violate a Validation Rule that was not active before?
- Is the Flow triggering a Process Builder or another Flow that updates the same record, spinning up an infinite loop?
- Is the Flow reaching for a field on a related record that does not exist?
{!$Record.Account.Owner.Name}with a null account lookup is the classic one.
Key takeaways
Logs first. FINEST level debugging on the affected user's profile gets you the exact failure point.
If the approval process throws an error, try switching the Flow's execution mode to 'System Context' to get past record-level permissions.
Use the Debug tool in Flow Builder rather than testing by hand in the UI, so you can watch the variables change in real time.
For complex automations, build a custom object to track and alert on errors. Standard Salesforce emails get filtered or ignored.
Leave a Comment