Soru

Zorluk: OrtaFlow Builder Elements and Logic

A Salesforce Administrator needs to configure a flow to update the Status field to 'Audited' across all child Asset records linked to an Account. To ensure the flow follows bulkification best practices and avoids exceeding governor limits, in what sequence should the administrator place the Flow Builder elements from start to finish?

  1. 1Execute a Get Records element to retrieve all Asset records associated with the target Account ID into a record collection variable.
  2. 2Pass the retrieved record collection into a Loop element to iterate through each Asset record individually.
  3. 3Use an Assignment element inside the loop to set the Status field on the current item from the loop to 'Audited'.
  4. 4Use a second Assignment element inside the loop to add the updated current item from the loop to a new record collection variable.
  5. 5Execute an Update Records element after the loop completes, passing the new record collection variable to perform the DML update.

Cevap

The correct sequence begins with retrieving the records into a collection, looping over each item, updating field values in memory using an Assignment element, adding the modified item to a staging collection using a second Assignment element, and finally issuing a single bulkified Update Records operation after the loop finishes.
The standard pattern for bulkified collection processing in Salesforce Flow Builder requires retrieving records, iterating over them in a loop, assigning field changes to the current item in memory, adding that item to an update collection, and executing a single Update Records element after the loop exits.

Adım Adım Çözüm

1
Query related child records
Obtain a collection of Asset records associated with the Account ID using a single Get Records query.
Data must be retrieved into memory prior to iteration to prevent executing SOQL inside loops.
2
Iterate through the collection
Enter the Loop element to access each Asset record one by one.
Looping exposes each record as a loop variable for individual attribute modification.
3
Assign updated field values
Set {!Loop_Asset.Status} to 'Audited' via an Assignment element.
Modifications must be made to the loop variable in memory.
4
Stage modified record into update collection
Add {!Loop_Asset} to {!varAssetsToUpdate} via an Assignment element.
Building a separate collection gathers all staged modifications for a bulk update.
5
Commit database updates outside the loop
Perform an Update Records operation on {!varAssetsToUpdate} after the loop path completes.
Executing DML outside of loop constructs enforces bulkification and adheres to Salesforce governor limits.

Anahtar Kavram

Flow Bulkification and Collection Processing
Bu soruyu puanla