Soru

Zorluk: OrtaFlow Resources and Data Manipulation

An administrator is designing a Flow on the Contract object. When a Contract status is updated to 'Under Review', the Flow must find all related Vendor Compliance records and update their 'Review Status' field to 'Pending Audit'. To ensure the Flow adheres to best practices and does not exceed Salesforce governor limits when processing multiple records, which two actions should the administrator take? (Choose two.)

  1. Add an Assignment element inside the Loop to add each updated record variable to a record collection variable.Cevap
  2. B
    Place an Update Records element inside the Loop immediately after each record field is modified.
  3. Place a single Update Records element after the Loop to update the record collection variable.Cevap
  4. D
    Place a Get Records element inside the Loop to query the latest field values for each related record individually.

Cevap

The administrator should use an Assignment element inside the Loop to add each modified record variable to a record collection variable, and then place a single Update Records element after the Loop to update the entire collection.
To follow Salesforce bulkification standards, all data manipulations must happen in memory during loop execution using Assignment elements, and DML operations must occur outside the loop using a single element acting on the collection variable. Adding each modified record to a record collection variable inside the Loop and issuing one Update Records element after the Loop achieves this requirement efficiently.

Adım Adım Çözüm

1
Retrieve related records using a single Get Records element prior to the Loop.
A collection of related Vendor Compliance records is retrieved into memory.
Prevents redundant SOQL queries and respects governor limits.
2
Iterate over the collection with a Loop element and use Assignment elements to modify field values and add the current loop item to a new collection variable.
All updated records are staged in an output record collection variable in memory.
Data manipulation in memory does not consume database DML limits.
3
Route the Loop's 'After Last Item' path to a single Update Records element referencing the output record collection variable.
All modified records are committed to the Salesforce database in a single bulkified operation.
Consumes only one DML statement regardless of how many records were iterated.

Anahtar Kavram

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