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?
- 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
- BPlace 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.
- CPerform 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.
- DConfigure 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
Key Concept
Bulkification of Flow Data Elements (SOQL and DML outside loops)