Bulkification and Error Handling in Flow
By the end of this lesson, you'll be able to:
- Explain why Get Records and DML-style elements should not sit inside a Loop
- Add a Fault Path to handle an element's potential failure gracefully
Prerequisites: Formulas and Variables in Flow
Bulkifying a Flow
The same governor-limit lesson from Apex applies to Flow — a Get Records or Update Records element placed inside a Loop runs once per loop iteration, and at high volume this can exhaust SOQL/DML limits exactly like unbulkified Apex would. The fix is the same shape too: collect everything needed into a collection variable first, then perform one bulk operation outside the loop.
Fault Paths
Any element capable of failing — Create Records, Update Records, an Action calling Apex or an external system — has an optional Fault Path. Connect it to handle the failure explicitly (log it, notify someone, show a friendly screen) rather than letting the Flow fail with a raw, user-hostile error message.
The bulk-safe restructuring pattern
Anti-pattern: Update Records element placed INSIDE a Loop
-> one DML statement per loop iteration, hits limits at scale
Bulk-safe pattern:
Loop -> Assignment (add updated record to a collection variable)
-> (after the loop ends) one Update Records element on the whole collection
This mirrors exactly the SOQL/DML-inside-a-loop lesson from Apex — collect changes during the loop, then perform a single bulk operation once, outside it.
Exercise
A Flow currently has an Update Records element inside a Loop, updating one Contact at a time. Describe how you'd restructure it to be bulk-safe.
Show hint
Think about what should move outside the loop, and what should happen inside it instead.
Bulkification and Error Handling in Flow — Quick Check
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
Just like Apex, a Flow's Get Records, Create Records, or Update Records element placed inside a Loop runs once per iteration and can hit governor limits at scale — and any element that can fail should have a Fault Path connected, so the Flow degrades gracefully instead of erroring out for the end user.