Question

Difficulty: HardFlow Builder Elements and Logic

A Salesforce Administrator needs to design an autolaunched flow that processes a list of inactive Partner Account records passed into the flow. For all open Opportunities associated with these Partner Accounts, the flow must update their Stage to 'Closed Lost'. To adhere to governor limits and bulkification best practices, all database modifications must occur outside any iteration loops. Arrange the Flow Builder elements in the correct sequential order to construct this bulkified automation.

  1. 1Get Records element to query all open Opportunity records where AccountId is in the input Partner Account collection.
  2. 2Loop element to iterate over the retrieved Opportunity record collection.
  3. 3Assignment element to set the StageName field of the current Opportunity loop item to 'Closed Lost'.
  4. 4Assignment element to add the modified current Opportunity loop item to a new Opportunity Record Collection variable.
  5. 5Update Records element placed after the loop finishes to update all records in the staging Opportunity Record Collection variable.

Answer

The correct sequence starts with retrieving the related records, looping through the retrieved collection, assigning updated field values to the loop item, adding the item to a secondary staging collection, and executing a single DML update outside the loop.
The proper design for handling child records in Salesforce Flow Builder follows the bulkification pattern: Get Records -> Loop -> Assignment (Modify Field) -> Assignment (Add to Collection) -> Update Records (Outside Loop). This guarantees that queries and DML operations execute exactly once per transaction regardless of collection size.

Step-by-Step Solution

1
Execute Get Records element for open Opportunities.
Obtain a record collection variable containing all targeted child records.
Bulk query must occur before looping to prevent executing SOQL queries inside a loop (SOQL governor limit).
2
Pass the Opportunity collection into a Loop element.
Set up iteration over each Opportunity item.
Flow logic must evaluate and update each record in the retrieved set sequentially in memory.
3
Add an Assignment element inside the loop to set StageName = 'Closed Lost'.
Update the field value of the current loop item variable.
Changes must be applied to the loop item variable prior to collection staging.
4
Add a second Assignment operation inside the loop to add current item to varOppsToUpdate collection.
Staging collection accumulates modified records across iterations.
Storing updated items in a separate collection enables bulk DML execution after loop completion.
5
Connect the 'After Last Item' path of the Loop to an Update Records element specifying varOppsToUpdate.
Single DML update statement updates all modified records in Salesforce.
Placing DML outside the loop ensures maximum performance and adheres to DML statement governor limits.

Key Concept

Flow Bulkification and Element Sequencing
Rate this question