Question

Difficulty: Very hardFlow Builder Elements and Logic

A Salesforce Administrator is designing an autolaunched flow to update all child Contact records whenever a parent Account's status changes. To adhere strictly to bulkification best practices and prevent hitting governor limits, in what precise order should the administrator execute the Flow Builder elements?

  1. 1Execute a Get Records element outside of any loop to retrieve all child Contact records whose AccountId matches the collection of updated Account IDs.
  2. 2Pass the retrieved Contact collection into a Loop element to iterate through individual record items.
  3. 3Use an Assignment element inside the loop to set updated field values on the current loop record variable.
  4. 4Use a second Assignment element inside the loop to add the modified loop record variable to a new Record Collection variable.
  5. 5Execute an Update Records element after the loop finishes, passing the new Record Collection variable into the DML operation.

Answer

The correct bulkified sequence begins by getting child Contact records into a collection, iterating through them with a Loop element, updating field values on the current item with an Assignment element, appending that item to a secondary collection with another Assignment element, and finally executing a single Update Records DML operation outside the loop.
The design pattern for bulkified Flow processing requires data retrieval (Get Records) prior to entering a loop, in-memory updates and staging (Assignment elements) inside the loop, and a single bulk write operation (Update Records) after the loop path completes.

Step-by-Step Solution

1
Retrieve child records before iteration
Child contacts are fetched in a single SOQL query call into a record collection.
Placing a Get Records element inside a loop causes governor limit violations (SOQL 101).
2
Iterate over the retrieved record collection
The flow evaluates one Contact record variable at a time in memory.
Looping allows row-by-row field assignment processing without database overhead.
3
Assign new field values
The current item variable in the loop receives updated values.
In-memory variable assignment does not consume DML governor limits.
4
Add updated item to target update collection
The secondary collection variable collects all staged updates.
Staging modified records in a secondary collection allows for a single bulk DML statement after iteration completes.
5
Perform DML update after loop execution finishes
All Contact updates persist to the database in a single transaction.
Executing DML outside the loop avoids hitting the 150 DML statements governor limit.

Key Concept

Bulkification in Flow Builder
Rate this question