An organization requires a Record-Triggered Flow on the Opportunity object that fires when an Opportunity reaches the 'Closed Won' stage. For each child Opportunity Line Item belonging to a specific Product Family, the automation must generate a corresponding custom Renewal Contract record and calculate an aggregated total renewal amount to update on the parent Account record. To adhere strictly to Salesforce governor limits and Flow Builder best practices, how should the administrator design the Flow elements and logic?
- Fetch child Opportunity Line Items using a Get Records element, iterate using a Loop element, use Assignment elements inside the loop to accumulate the renewal amount into a Currency variable and add instantiated Renewal Contract records to a Record Collection variable, then invoke a single Create Records element and a single Update Records element outside the loop.Answer
- BIterate through each child Opportunity Line Item using a Loop element, execute a Get Records element inside the loop to pull product details, and execute a Create Records element inside the loop to immediately create each Renewal Contract record.
- CConfigure the automation as a Before-Save (Fast Field Updates) Record-Triggered Flow on the Opportunity object, incorporating the Loop element to create child Renewal Contract records and update the parent Account record directly.
- DCreate a Roll-Up Summary field on the Account object to sum Opportunity Line Item values across lookup relationships, eliminating the need for Assignment or Update Records elements within the flow logic.
Answer
Use a Get Records element to retrieve line items, iterate through them with a Loop element, collect instantiated records into a collection variable and sum metrics using Assignment elements, and perform DML operations using Create Records and Update Records elements placed outside the loop.
Bulkification in Flow Builder requires accumulating data changes in variable collections during iteration and executing a single database element outside the loop. Using Assignment elements within the loop to populate a Record Collection and aggregate amounts, followed by executing Create Records and Update Records outside the loop, keeps SOQL and DML counts at 1 regardless of the number of line items processed.
Step-by-Step Solution
Key Concept
Flow Builder Bulkification and Data Manipulation Logic