An administrator is creating an autolaunched flow to process a collection of Contract records associated with an Account whenever the Account tier is upgraded. The flow must update the Status field to 'In Review' on each associated Contract record and persist these changes back to Salesforce. Which design pattern should the administrator implement to ensure the flow executes efficiently without hitting governor limits?
- Iterate through the Contract collection using a Loop element, use an Assignment element inside the loop to set updated field values on the current item and append it to a target Record Collection Variable, and place a single Update Records element outside the loop referencing the target collection.Answer
- BIterate through the Contract collection using a Loop element, update the field values on the current record item, and execute an Update Records element inside the loop during each iteration.
- CPlace a Get Records element inside a Loop element to re-fetch each Contract record, update the values directly on the retrieved record, and invoke a single Update Records element at the end of the flow referencing the Account record.
- DUse a Decision element inside a Loop element to clear the existing collection, assign the modified values to a single Record Variable, and execute a Create Records element inside the loop to insert duplicate contracts.
Answer
Iterate through the Contract collection using a Loop element, use an Assignment element inside the loop to set updated field values on the current item and append it to a target Record Collection Variable, and place a single Update Records element outside the loop referencing the target collection.
To process multiple records efficiently in Salesforce Flow, field assignments should be staged in memory using an Assignment element inside the Loop. The modified items are added to a separate Record Collection Variable, and a single Update Records element is executed outside the loop to commit all updates in bulk.
Step-by-Step Solution
Key Concept
Flow Bulkification and Collection Processing