Creating an Infinite Loop with Record-Triggered Flows
“Flow updates record. Update triggers Flow. Flow updates record. Repeat until Salesforce gives up.”
What Happened
Built a record-triggered Flow on Account that updated a 'Last Modified Reason' field whenever any field changed. The Flow's own update to Last Modified Reason counted as a field change. Which triggered the Flow again. The Flow ran 50 times and Salesforce killed it. But not before it consumed all the org's CPU time, and every other user got 'unable to lock row' errors for 10 minutes.
The Wrong Way
Record-Triggered Flow: Account - After Save
Entry Conditions: "A record is updated"
→ No conditions (fires on ANY change)
Actions:
→ Update Records: Current Account
→ Last_Modified_Reason__c = "Updated at " & TEXT(NOW())
// Flow changes Last_Modified_Reason__c
// That change triggers the flow again
// That change triggers the flow again...
// Maximum flow trigger depth exceededThe Right Way
Record-Triggered Flow: Account - After Save
Entry Conditions: "A record is updated"
→ Condition Requirements: "All Conditions Are Met"
→ $Record.Last_Modified_Reason__c EQUALS $Record__Prior.Last_Modified_Reason__c
→ (i.e., only fire when Last_Modified_Reason HASN'T changed)
// OR better: use a checkbox to prevent re-entry
Entry Conditions:
→ $Record.Flow_Processing__c EQUALS False
Actions:
→ Update Records: Current Account
→ Flow_Processing__c = True
→ Last_Modified_Reason__c = "Field X changed"
// Separate Before-Save Flow to reset the flag
Before Save Flow:
→ Set Flow_Processing__c = False (doesn't count as DML)The Lesson
If your Flow updates the same object it triggers on, you MUST add entry conditions that prevent re-entry. Check that the fields you're setting aren't the same fields that trigger the Flow.
Enjoyed this? Get more like it.
Glen's Musings — AI, investing, and building things. Occasional. Free.
More Admin Mistakes
Validation Rules That Block Your Own Automations
Your validation rule doesn't care if a Flow or trigger made the change.
Read moreAnnoyingManaging Access with Profiles Instead of Permission Sets
Profiles are for login settings. Permission Sets are for everything else.
Read morePainfulWorkflow Rules, Process Builder, and Flows All Running on the Same Object
Three automation tools on one object means nobody knows what's happening.
Read more