Question

Difficulty: Very hardFlow Resources and Data Manipulation

An administrator is designing an autolaunched flow in Salesforce to update thousands of high-priority Account records and their associated Contacts whenever a custom status field changes. To meet performance guidelines and avoid hitting SOQL query and DML statement governor limits, the flow must handle data operations efficiently across collections. Which TWO actions should the administrator take to process these records without violating governor limits?

  1. Execute a Get Records element before entering the loop to retrieve all necessary records into a Record Collection Variable.Answer
  2. Use an Assignment element inside the loop to add updated record variables to a Record Collection Variable, followed by a single Update Records element outside the loop.Answer
  3. C
    Place an Update Records element inside the Loop element to immediately save changes for each individual record during iteration.
  4. D
    Add a Get Records element inside the Loop element to query related Contact records dynamically on each iteration cycle.

Answer

The administrator should execute a Get Records element prior to the loop to populate a collection variable and use an Assignment element inside the loop to accumulate modified records into a collection, executing a single Update Records element outside the loop.
Bulkifying flows requires moving all database interactions outside of loop containers. Querying records before entering the loop retrieves data in a single SOQL statement, and gathering updated record variables into a collection variable via Assignment elements allows a single Update Records DML operation outside the loop to commit all updates simultaneously.

Step-by-Step Solution

1
Query records before processing
Obtain all targeted records in a single SOQL database operation stored within a Record Collection Variable.
Prevents running separate SOQL queries inside repeated loop iterations.
2
Loop and modify variables
Iterate through each item in the collection, updating field values on the loop item variable.
Modifies data in system memory without issuing DML calls to the database.
3
Stage modified records into an output collection
Use an Assignment element within the loop to add the modified loop item variable to a separate output Record Collection Variable.
Prepares all changed records into a unified collection for bulk processing.
4
Execute bulk DML operation outside the loop
Pass the output Record Collection Variable into a single Update Records element placed after the loop finishes.
Consumes only one DML statement out of the transaction governor limit regardless of record count.

Key Concept

Flow Bulkification and Governor Limits
Rate this question