Debugging Flows Like a Developer: Beyond the Debug Log
Most admins debug flows by clicking "Debug" in Flow Builder and stepping through manually. That works for simple flows, but the moment you have subflows, record-triggered flows, or platform events, the built-in debugger falls apart. You need a real strategy.
The trick is to use custom debug actions. Create a reusable subflow called "Debug_Logger" that accepts a text input and creates a custom object record (Flow_Debug_Log__c) with the timestamp, flow name, and variable values. Wire it into your flows behind a custom metadata toggle (Flow_Debug_Settings__mdt) so you can turn logging on and off without editing the flow. In production, the toggle is off and there is zero performance cost.
Pair this with Setup > Debug Logs filtered to "Workflow" category for record-triggered flows. The debug log shows you the exact order of execution: validation rules, before-save flows, after-save flows, and process builders. When flows interact with each other, this execution order is the only way to find the real problem.
Code Example
// Flow_Debug_Log__c custom object:
// - Flow_Name__c (Text)
// - Message__c (Long Text)
// - Variable_Snapshot__c (Long Text)
// - Timestamp__c (DateTime)
// In your flow:
// 1. Get Records: Flow_Debug_Settings__mdt
// WHERE DeveloperName = "Default"
// 2. Decision: Is {!debugSettings.Enable_Logging__c} = TRUE?
// YES → Subflow: Debug_Logger
// Input: flowName = "My_Record_Triggered_Flow"
// Input: message = "Entry criteria met"
// Input: snapshot = {!$Record.Name} & " | " & TEXT({!$Record.Amount})
// NO → Continue without logging
// Toggle logging in production:
// Setup → Custom Metadata → Flow_Debug_Settings → Enable_Logging = true
// (No deployment needed, no flow edit needed)Need this implemented in your org?
I've shipped these patterns in production for 10+ years.
View Consulting →Enjoyed this? Get more like it.
Glen's Musings — AI, investing, and building things. Occasional. Free.
More Flows Tips
Flow Performance: The Bulkification Patterns That Actually Matter
Salesforce flows run in bulk by default when triggered by data loads, but most admins build them assuming one record at ...
Read moreIntermediateScheduled Flow Gotchas: The 250K Record Trap and Batch Windows
Scheduled flows look simple: pick an object, set criteria, choose a schedule, done. But there are three gotchas that wil...
Read more