An administrator needs to build an autolaunched flow that processes nightly updates for a custom object named Service Contract. For each active Service Contract record, the flow must iterate over all related Line Item records (linked via a lookup relationship), calculate the total contracted value using an Assignment element, and set a custom Status field on each Line Item to 'Archived'. The solution must process thousands of records efficiently without hitting SOQL or DML governor limits. Which design pattern correctly utilizes Flow Builder elements and logic to meet these requirements?
- Execute a Get Records element before the loop to retrieve all related Line Items into a record collection, use an Assignment element inside the loop to accumulate line values and add updated Line Item records to a secondary collection variable, and execute a single Update Records element on the secondary collection outside the loop.Answer
- BPlace a Get Records element inside the loop for each Service Contract to fetch its child Line Items, update the Status field using an Assignment element, and invoke an Update Records element inside the loop immediately after each assignment.
- CCreate a Roll-Up Summary field on the Service Contract object to automatically aggregate the Line Item values over the lookup relationship, allowing the flow to skip collection assignments and execute an Update Records element directly on the parent object.
- DUse a Decision element inside the loop to verify the picklist values assigned to the Service Contract Record Type, and use a Create Records element inside the loop to clone each Line Item with the 'Archived' status.
Answer
The correct design executes a Get Records element before entering the loop to fetch child Line Items into a collection, uses Assignment elements within the loop to update record variables and build a secondary update collection, and then performs a single Update Records operation on the collection after exiting the loop.
Bulkification is mandatory when designing flows in Salesforce. Performing data operations (Get Records, Create Records, Update Records, Delete Records) outside of loops ensures that all queries and database commits are executed in single batch calls rather than repeated per item, adhering strictly to transaction governor limits.
Step-by-Step Solution
Key Concept
Bulkification in Flow Builder (Data operations outside loops)
Estimated Time:2m 0s