Soru

Zorluk: OrtaFlow Resources and Data Manipulation

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?

  1. A
    Place an Update Records element inside the Loop element to save changes to the database during each iteration.
  2. B
    Configure 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.
  3. 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.Cevap
  4. D
    Add a Get Records element inside the Loop element to retrieve the fresh data of each Shipment Item record prior to making assignments.

Cevap

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.

Adım Adım Çözüm

1
Retrieve the target child records
A record collection variable containing all related Shipment Item records is stored in memory via a single Get Records element.
Data must be retrieved in bulk outside of any loop to consume only one SOQL query.
2
Loop through the collection and update field values in memory
For each iteration, the loop uses the current item record variable to modify the field values, then an Assignment element appends that modified record variable to a new record collection variable.
Record modifications are staged in memory without invoking database operations inside the loop.
3
Perform a single DML operation after the loop completes
An Update Records element executes on the newly populated record collection variable after the loop concludes.
Executing DML on the entire collection consumes exactly one DML statement regardless of how many records were processed.

Anahtar Kavram

Bulkification in Flow Builder using Loop elements, Assignment elements, and Collection variables
Tahmini Süre:1m 15s
Bu soruyu puanla