An administrator is designing a record-triggered flow that executes whenever an Opportunity is updated. The flow must calculate the sum of the Amount values from all related custom Payment records and update a field on the Opportunity. Which approach correctly retrieves and calculates this sum while strictly avoiding Salesforce governor limit violations during bulk updates?
- Use a Get Records element to retrieve related Payment records, iterate through the collection with a Loop element using an Assignment element to add each amount to a Number variable, and execute a single Update Records element after the loop finishes.Cevap
- BUse a Get Records element to retrieve related Payment records, iterate through them with a Loop element, and place an Update Records element inside the loop to increment the Opportunity field for each record.
- CCreate a Roll-Up Summary field on the Opportunity object to sum the Payment Amount, using a Lookup relationship between Payment and Opportunity.
- DUse a Decision element inside a loop to update the Record Type picklist assignment directly on each child Payment record before performing a Get Records query inside the loop.
Cevap
Use a Get Records element to retrieve related Payment records, iterate through the collection with a Loop element using an Assignment element to add each amount to a Number variable, and execute a single Update Records element after the loop finishes.
The correct approach bulkifies database operations by gathering records with a single query, performing mathematical aggregation in memory via an Assignment element inside the loop, and committing changes with a single Update Records element after loop execution completes.
Adım Adım Çözüm
Anahtar Kavram
Bulkification and DML/SOQL Governor Limit Avoidance in Flow Builder
Tahmini Süre:1m 30s