Question

Difficulty: Very hardFlow Builder Elements and Logic

A business process requires an autolaunched flow to update entitlement balances on parent Account records when child Subscription records reach their expiration date. The flow receives a collection variable containing multiple Account record IDs. To maintain optimal performance and prevent runtime exceptions when processing large batches of records, which logical sequence and placement of Flow elements must be implemented?

  1. Perform a single Get Records operation before entering the loop to fetch all relevant active Subscriptions, iterate through the Account collection using a Loop element, use Assignment elements inside the loop to accumulate totals into a record collection variable, and execute a single Update Records operation after the loop finishes.Answer
  2. B
    Place a Get Records element inside the Account loop to query active Subscriptions for each Account ID individually, calculate totals with an Assignment element, and execute a single Update Records operation outside the loop.
  3. C
    Perform a single Get Records operation outside the loop, iterate through the Account collection using a Loop element, compute the entitlement total, and execute an Update Records element inside the loop for each Account iteration.
  4. D
    Configure a before-save Record-Triggered Flow on the Subscription object that iterates through parent Account records within a loop to execute immediate database updates whenever a Subscription status changes.

Answer

The correct architecture requires executing all Get Records and Update Records elements outside of the Loop element, using Assignment elements inside the loop to manipulate memory collection variables.
The correct implementation adheres to Salesforce bulkification design principles by isolating all database interactions (Get Records and Update Records) outside the Loop element. By fetching data in bulk before entering the loop and accumulating modified parent records in a collection variable using Assignment elements, the flow commits all record updates using a single DML operation upon loop completion.

Step-by-Step Solution

1
Query records in bulk
Fetch all relevant child Subscription records for the target Accounts in a single Get Records element prior to loop execution.
Prevents executing SOQL queries inside the loop, conserving transaction governor limits.
2
Iterate and process in memory
Use a Loop element combined with Assignment elements to calculate aggregate totals and populate a record collection variable in memory.
In-memory variable manipulation does not consume Salesforce database governor limits.
3
Commit changes in bulk
Pass the populated record collection variable to a single Update Records element positioned after the loop output path.
Executes a single bulk DML statement for all updated parent Account records.

Key Concept

Bulkification of Flow Data Elements (SOQL and DML outside loops)
Rate this question