Question

Difficulty: EasyFlow Resources and Data Manipulation

An administrator needs to update multiple Contact records associated with an Account using a Flow. To prevent exceeding Salesforce governor limits during execution, what is the recommended placement of the Update Records element when iterating through a collection of records?

  1. Outside of the Loop element, executing a single update on the modified record collection after the loop completesAnswer
  2. B
    Inside the Loop element immediately after assigning new values to each item in the collection
  3. C
    Inside the Loop element prior to the Assignment element to verify existing field values
  4. D
    Inside a Decision element within the loop body to conditionally commit changes for each record individually

Answer

Place the Update Records element outside the Loop element, executing the DML update on the entire collection variable once after all assignments are complete.
Salesforce enforces strict governor limits on data manipulation language (DML) statements (150 per transaction). To ensure flows are bulkified, data manipulation elements like Update Records should always be placed outside the Loop element on the 'After Last Item' path. Records should be modified in memory via Assignment elements and stored in a collection variable before performing a single bulk DML update.

Step-by-Step Solution

1
Iterate through the record collection using a Loop element and update field values in memory using an Assignment element.
Individual items are updated in temporary memory without invoking DML statements.
Prevents database operations within loop iterations.
2
Add the updated current item from the loop to a new record collection variable using a second Assignment element.
A collection of modified records is constructed.
Gathers all modified records into a single bulk resource.
3
Place an Update Records element after the loop finishes (connected to the 'After Last Item' path) pointing to the collection variable.
All records in the collection are updated in a single bulk DML statement.
Adheres to Salesforce governor limits by executing only one DML operation.

Key Concept

Flow Bulkification and Governor Limits
Estimated Time:1m 0s
Rate this question