Sub topic 16
Debugging and Monitoring Runs
This chapter assumes you can build an autolaunched or schedule-triggered flow, add a fault path, and activate a version. Here you will test a flow before release and find out what happened after it ran.
Debug in Flow Builder
The Debug button in Flow Builder runs the open version. For an autolaunched flow, you enter values for the input variables. For a schedule-triggered flow, you pick the records to test against. Two options matter most:
- Run flow in rollback mode undoes all data changes at the end of the debug run. It is the safe choice for Create, Update, and Delete elements.
- Show details of what happens when the flow executes lists each element, the values it read, and the values it wrote.
A debug run is not a real run. Debug runs of scheduled flows do not wait for the schedule, and some limits and context details differ from production.
Read the debug output
The output lists elements in the order they executed. Check three things:
- Did a Decision take the outcome you expected?
- Does a Get Records element return the records you expected, or none?
- Do the output variables hold the final values you expected?
If a fault path fired, the output shows the error message stored in $Flow.FaultMessage.
Find runs after activation
Debug runs only cover what you test by hand. In production, use these Setup pages:
| Need | Where to look |
|---|---|
| Upcoming and past scheduled runs | Setup > Scheduled Jobs, and Setup > Paused and Failed Flow Interviews |
| Interviews that paused or failed | Setup > Paused and Failed Flow Interviews |
| Apex-level detail, limits, and errors | Setup > Debug Logs |
| Background job status | Setup > Apex Jobs |
An interview is one running instance of a flow. Each failed interview that has no fault path produces an error email to the person who last modified the flow.
Capture errors yourself
An unhandled error is hard to find later. A fault path can record it first. This sketch writes the message to a custom log object. The object and fields are examples you create yourself.
<recordCreates>
<name>Log_Error</name>
<label>Log Error</label>
<inputAssignments>
<field>Flow_Name__c</field>
<value>
<stringValue>Close_Stale_Cases</stringValue>
</value>
</inputAssignments>
<inputAssignments>
<field>Message__c</field>
<value>
<elementReference>$Flow.FaultMessage</elementReference>
</value>
</inputAssignments>
<object>Flow_Error_Log__c</object>
</recordCreates>Common errors
- Testing only one record. A flow that works for one record can hit a governor limit on many. Debug with several records, and read the production logs for limit errors.
- Debugging without rollback. The flow changes real data.
- Looking at the wrong version. Debug runs use the open version. Production runs use the active version.
- Missing running user. Scheduled flows run as the Automated Process user unless configured otherwise. Permission errors may appear only in production.
Exercise
A scheduled flow works in debug but updates no records at 2:00 AM. Name two places to check and what each shows.
Show answer
Setup > Scheduled Jobs shows whether the run was queued and when it ran. Setup > Paused and Failed Flow Interviews and the debug log show errors, and the log also shows the running user. Also confirm the active version's record filter returns records.