Soru

Zorluk: KolayFlow Resources and Data Manipulation

An administrator is designing an autolaunched Flow to update a field across multiple child records processed within a Loop element. To follow Salesforce best practices and prevent hitting DML governor limits, how should the data manipulation elements be configured?

  1. Add updated records to a Record Collection Variable inside the loop, then execute a single Update Records element outside the loop.Cevap
  2. B
    Place an Update Records element inside the Loop element to update each record individually during every iteration.
  3. C
    Place a Get Records element inside the Loop element to fetch updated values before applying an immediate update.
  4. D
    Use an Assignment element inside the loop to commit DML changes directly to the database for each record.

Cevap

Collect the modified records into a record collection variable inside the loop using an Assignment element, and execute a single Update Records element after the loop finishes.
Salesforce governor limits dictate that DML elements (Create, Update, Delete) and SOQL queries (Get Records) should never be placed inside loops. The recommended pattern is to modify records in memory, add them to a record collection variable using an Assignment element inside the loop, and then perform a single bulk DML operation using an Update Records element outside the loop.

Adım Adım Çözüm

1
Modify field values on the loop item variable.
Field values are updated in local memory for the current iteration item.
In-memory changes do not trigger database operations or count against governor limits.
2
Use an Assignment element inside the loop to add the modified loop item to a Record Collection Variable.
The updated record is stored in a collection in memory.
Accumulating records into a collection prepares them for bulk DML processing.
3
Pass the Record Collection Variable to a single Update Records element placed after the loop path.
All collection records are updated in a single database transaction.
Executing DML once outside the loop uses only 1 DML statement regardless of record volume.

Anahtar Kavram

Flow Bulkification and Loop Placement Best Practices
Bu soruyu puanla