Soru

Zorluk: OrtaFlow Resources and Data Manipulation

An administrator is designing an autolaunched flow to update the Billing Status field to 'Billed' on all related Timesheet Entry records whenever a parent Consulting Project status changes to 'Completed'. To adhere to Salesforce best practices and avoid hitting governor limits, in what sequential order should the administrator configure the flow elements?

  1. 1Execute a Get Records element to query all open Timesheet Entry records related to the parent Consulting Project into a record collection variable.
  2. 2Pass the retrieved Timesheet Entry collection variable into a Loop element to iterate through each individual record.
  3. 3Use an Assignment element inside the loop path to set the Billing Status field to 'Billed' on the current loop item record variable.
  4. 4Use a second Assignment element inside the loop path to add the modified loop item record variable into a new record collection variable.
  5. 5Execute an Update Records element along the 'After Last Item' path of the loop to commit the new record collection variable to the database in a single DML operation.

Cevap

1. Query records using Get Records into a collection; 2. Iterate using a Loop element; 3. Modify the current item's field using an Assignment element; 4. Add the modified item to a new collection using an Assignment element; 5. Commit the collection using an Update Records element outside the loop.
The standard and efficient bulkification pattern in Salesforce Flow requires first retrieving records with a Get Records element into a collection, passing that collection into a Loop element, modifying the current record variable via an Assignment element, appending that modified record variable to an update collection variable with a second Assignment element, and finally executing an Update Records element on the entire collection after the loop completes.

Adım Adım Çözüm

1
Query related child records using a Get Records data element.
A record collection variable containing all related Timesheet Entry records is populated in memory.
Data manipulation requires the target records to be retrieved into the flow context first.
2
Route the collection into a Loop element.
The flow initializes iteration and assigns the first record to the loop item variable.
Flow cannot update individual field values across multiple records simultaneously without iterating over the collection.
3
Assign the new field value to the current loop item variable.
The in-memory record variable's Billing Status is changed to 'Billed'.
Field changes must be made to the specific record variable before adding it to the staging collection.
4
Add the modified record variable to a new collection variable using the 'Add' operator in an Assignment element.
The new collection variable holds all staged, modified records across loop iterations.
Accumulating records in a dedicated collection variable allows a single bulkified update after iteration completes.
5
Place an Update Records element after the loop finishes ('After Last Item').
All modified records in the collection variable are committed to the Salesforce database in a single transaction.
Placing DML statements outside of loops ensures compliance with Salesforce Flow governor limits.

Anahtar Kavram

Bulkification Pattern in Salesforce Flow using Collections, Loops, and Assignment Elements
Bu soruyu puanla