Soru

Zorluk: OrtaFlow Resources and Data Manipulation

An administrator needs to build an autolaunched flow that calculates the total cost of all line items associated with a Work Order and updates a custom total field on the parent Work Order. Which design approach correctly utilizes flow resources and data elements while preventing SOQL and DML governor limit exceptions?

  1. Use a Get Records element to retrieve all related Work Order Line Items into a collection, use a Loop with an Assignment element to sum the line item costs into a currency variable, and place an Update Records element outside the loop.Cevap
  2. B
    Use a Get Records element to retrieve line items, iterate through the collection, and execute an Update Records element inside the loop after adding each line item cost.
  3. C
    Place a Get Records element inside a loop to query each Work Order Line Item individually, adding its cost to a currency variable during each iteration.
  4. D
    Use a Loop element with an Assignment element to create and insert a new Work Order record with an updated cost inside the loop on each iteration.

Cevap

Use a Get Records element to retrieve all related Work Order Line Items into a collection, use a Loop with an Assignment element to sum the line item costs into a currency variable, and place an Update Records element outside the loop.
The correct approach uses a single Get Records element to populate a record collection before looping. Inside the loop, an Assignment element accumulates the cost into a variable without invoking database calls. Finally, a single Update Records element updates the parent record outside the loop. This follows Salesforce bulkification design principles.

Adım Adım Çözüm

1
Query related records bulkified
A single Get Records element retrieves the collection of Work Order Line Items before entering any loop.
Prevents hitting SOQL query governor limits by querying all required records in a single database transaction.
2
Aggregate values in memory
A Loop element iterates over the collection, using an Assignment element to add each line item cost to a number/currency flow variable.
Calculations and assignments occur in flow memory without issuing database calls.
3
Execute DML outside the loop
An Update Records element executes after loop completion to update the parent Work Order record.
Ensures DML operations are bulkified and executed only once per flow execution.

Anahtar Kavram

Flow Bulkification and Governor Limits
Bu soruyu puanla