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?
- 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
- BUse 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.
- CPlace 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.
- DUse 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
Anahtar Kavram
Flow Bulkification and Governor Limits