An administrator is designing an autolaunched flow that processes multiple Shipment Item records related to a returned Shipment. The flow retrieves all related shipment items, sets the Return Status field to 'Returned to Inventory' on each record, and saves the changes. To adhere to Salesforce best practices and avoid hitting governor limits when processing large batches of records, what should the administrator do?
- APlace an Update Records element inside the Loop element to save changes to the database during each iteration.
- BConfigure a before-save record-triggered flow on the parent Shipment record to automatically commit field updates to all related child records without using DML elements.
- Iterate through the retrieved collection using a Loop element, update the current item variable, add each updated item to a new collection variable using an Assignment element, and execute a single Update Records element on the new collection outside the loop.Answer
- DAdd a Get Records element inside the Loop element to retrieve the fresh data of each Shipment Item record prior to making assignments.
Answer
Iterate through the retrieved collection using a Loop element, update the current item variable, add each updated item to a new collection variable using an Assignment element, and execute a single Update Records element on the new collection outside the loop.
The correct pattern follows Salesforce Flow bulkification standards: records are processed in memory using the loop's current item variable, added to a new record collection variable using an Assignment element (`collectionVariable Add currentItemVariable`), and finally updated in a single Update Records DML operation positioned after the loop finishes. This consumes only one DML statement across all iterations.
Step-by-Step Solution
Key Concept
Bulkification in Flow Builder using Loop elements, Assignment elements, and Collection variables
Estimated Time:1m 15s