Question

Difficulty: HardFlow Resources and Data Manipulation

An administrator is designing an autolaunched flow to update secondary contact details across multiple related Contact records whenever a Partner Account undergoes a tier recalculation. To process the updates efficiently and avoid hitting SOQL and DML governor limits, which two design patterns should the administrator implement when manipulating record data in the flow?

  1. Iterate through the Contact collection using a Loop element, use an Assignment element to modify the fields on the current loop item, and use a second Assignment element to add the loop item to a new output collection variable.Answer
  2. B
    Place an Update Records element directly inside the Loop element after updating the current loop item's fields to commit changes immediately on each iteration.
  3. Place a single Update Records element after the loop completes and pass the staged collection variable containing all modified Contact records to execute a bulk DML statement.Answer
  4. D
    Use a Get Records element inside the Loop element to retrieve the latest related parent Account data for each individual Contact record prior to assignment.

Answer

The administrator should use Assignment elements inside the loop to modify fields and stage items into a collection variable, and then execute a single Update Records element outside the loop using that collection variable.
To follow Flow bulkification best practices, data manipulation must be performed in memory while inside a loop using Assignment elements to stage changes in a collection variable. Once the loop finishes, a single Update Records element is executed using the collection variable to update all records in one transaction statement.

Step-by-Step Solution

1
Retrieve related records into a collection variable outside of any loops
Obtain all target records using a single Get Records element, consuming only 1 SOQL query.
Prevents issuing SOQL queries inside a loop.
2
Loop through the collection and stage changes in memory
In each iteration, update field values on the loop item using an Assignment element, then add the item to a new output collection variable using a second Assignment element.
In-memory collection manipulation does not count against governor limits.
3
Perform bulk DML operation after loop completion
Pass the staged collection variable into an Update Records element placed after the loop path finishes.
Executes a single bulk update, consuming only 1 DML statement for all processed records.

Key Concept

Flow Bulkification and Collection Data Manipulation Best Practices
Estimated Time:2m 0s
Rate this question