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?
- 1Execute a Get Records element to query all open Timesheet Entry records related to the parent Consulting Project into a record collection variable.
- 2Pass the retrieved Timesheet Entry collection variable into a Loop element to iterate through each individual record.
- 3Use an Assignment element inside the loop path to set the Billing Status field to 'Billed' on the current loop item record variable.
- 4Use a second Assignment element inside the loop path to add the modified loop item record variable into a new record collection variable.
- 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
Anahtar Kavram
Bulkification Pattern in Salesforce Flow using Collections, Loops, and Assignment Elements