Question

Difficulty: MediumFlow Builder Elements and Logic

A Salesforce Administrator needs to design a record-triggered flow that executes when an Opportunity status updates to 'Closed Won'. The flow must iterate through all associated Opportunity Line Item records, set a custom checkbox field `Renewal_Ready__c` to true, and commit the updates to the database while adhering to bulkification best practices. In what sequential order should the administrator configure the Flow Builder elements?

  1. 1Add a Get Records element to retrieve all Opportunity Line Items where OpportunityId equals $Record.Id.
  2. 2Add a Loop element to iterate through the retrieved collection of Opportunity Line Items.
  3. 3Add an Assignment element inside the loop to set Renewal_Ready__c = True on the current loop item and add the item to a new record collection variable.
  4. 4Add an Update Records element on the 'After Last' path of the Loop to update the new record collection variable.

Answer

The correct logical sequence is: 1) Query the related child records using Get Records, 2) Iterate over the record collection using a Loop element, 3) Update field values on the loop item and stage it in a new collection variable using an Assignment element inside the loop, and 4) Commit all updates with a single Update Records element after the loop completes.
To process related child records effectively without exceeding Salesforce governor limits, a flow must retrieve the child collection first, iterate using a Loop element, use Assignment elements inside the loop to update record values in memory and stage them into a collection variable, and finally execute a single Update Records element on the 'After Last' loop path.

Step-by-Step Solution

1
Retrieve related child records
All Opportunity Line Item records linked to the trigger Opportunity are stored in a record collection variable.
Flow requires record data to be fetched before field-level modifications can occur.
2
Iterate through the retrieved collection
Each line item is made accessible sequentially using the loop item variable.
Looping allows the flow to iterate through individual items within the record collection.
3
Stage modified records in memory
Field values are altered on the loop variable and added to a secondary record collection variable.
Updating records in memory avoids placing database DML statements inside the loop body.
4
Execute a single bulkified update
All modified line items in the secondary collection are updated in the database at once.
Placing the Update Records element outside the loop on the 'After Last' path respects Salesforce SOQL/DML governor limits.

Key Concept

Bulkification in Flow Builder using Loops, Assignment elements, and Collection Variables
Rate this question