What are the Flow Builder best practices for bulkification and avoiding governor limit issues?
Suggested answer
Flows can process up to 200 records per transaction (matching Apex trigger batch size). Common governor limit pitfalls and how to avoid them:
SOQL in loops: Never use a Get Records element inside a loop. Collect all filter values into a collection variable first, then use a single Get Records element outside the loop with a filter condition on the collection. This reduces SOQL queries from N to 1.
DML in loops: Accumulate records to create/update/delete in collection variables. Use a single Create Records, Update Records, or Delete Records element after the loop to bulk-process the collection in one DML statement.
Limit nesting: Deeply nested decision/loop structures increase transaction complexity. Use sub-flows (Auto-Launched Flow called from another flow) to modularise logic and improve maintainability.
Before-save vs after-save: Use before-save record-triggered flows for field updates on the triggering record — they are faster and don't consume an additional DML operation. Use after-save for creating/updating related records.
Flow limits: Maximum 250 DML statements, 100 SOQL queries per transaction (shared with triggers and Apex in the same transaction).
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.