An administrator needs to build an autolaunched Flow that updates all open Opportunity records associated with an Account when the Account's rating changes. The Flow retrieves the related opportunities into a record collection using a Get Records element and processes them using a Loop element. Which design pattern should the administrator implement to efficiently update the records while adhering to Salesforce governor limit best practices?
- Use an Assignment element inside the Loop to update field values on the current record item, a second Assignment element inside the Loop to add the updated record to a new collection variable, and a single Update Records element outside the Loop.Answer
- BPlace an Update Records element directly inside the Loop element immediately following an Assignment element that modifies each Opportunity record variable.
- CConvert the Account and Opportunity relationship to Master-Detail and place a Get Records element inside the Loop element to calculate roll-up summary values for each opportunity.
- DUse a Decision element inside the Loop to assign a new Record Type to each Opportunity without configuring available picklist values for that destination Record Type.
Answer
Use an Assignment element inside the Loop to update field values on the current record item, a second Assignment element inside the Loop to add the updated record to a new collection variable, and a single Update Records element outside the Loop.
The correct design pattern follows Salesforce flow bulkification standards: field updates are staged in memory using Assignment elements inside the loop, collected into a secondary Record Collection variable, and saved to the database in a single transaction via an Update Records element placed after the loop finishes.
Step-by-Step Solution
Key Concept
Bulkification and DML placement in Salesforce Flow Builder