Question

Difficulty: HardFlow Builder Elements and Logic

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?

  1. 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
  2. B
    Place 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.
  3. C
    Create 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.
  4. D
    Use 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

1
Query records efficiently
All child Line Item records are retrieved in a single SOQL query before any iteration occurs.
Executing data queries outside loops prevents reaching the limit of 100 SOQL queries per transaction.
2
Iterate and modify in-memory variables
The flow loops through the collection, uses an Assignment element to sum values, updates field values in memory, and adds the modified record variable to a new Record Collection variable.
In-memory variable manipulation does not consume database governor limits.
3
Commit changes in a bulkified operation
A single Update Records element processes the entire modified Record Collection variable after the loop finishes.
Executing a single DML operation outside the loop ensures the flow stays well within the 150 DML statements governor limit.

Key Concept

Bulkification in Flow Builder (Data operations outside loops)
Estimated Time:2m 0s
Rate this question