Soru

Zorluk: OrtaFlow Builder Elements and Logic

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?

  1. 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
  2. B
    Use 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.
  3. C
    Create a Roll-Up Summary field on the Opportunity object to sum the Payment Amount, using a Lookup relationship between Payment and Opportunity.
  4. D
    Use 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

1
Query related child records using a Get Records element outside any loop.
Obtain a record collection variable containing all related Payment records.
Retrieving data in a single query outside loops prevents hitting SOQL governor limits.
2
Loop through the record collection and use an Assignment element to accumulate total amounts into a variable.
Calculate the total sum in memory without issuing database updates inside the loop.
Assignment elements perform in-memory variable operations which do not consume DML governor limits.
3
Place the Update Records element on the path after the loop completes.
Update the parent Opportunity record in a single DML operation.
Executing DML operations outside the loop ensures the flow remains fully bulkified and compliant with governor limits.

Anahtar Kavram

Bulkification and DML/SOQL Governor Limit Avoidance in Flow Builder
Tahmini Süre:1m 30s
Bu soruyu puanla