Question

Difficulty: HardFlow Builder Elements and Logic

An administrator needs to build a Flow that updates a group of expired Asset records for a target Account and creates a single notification Task for the Account owner. To ensure the flow executes efficiently without exceeding Salesforce governor limits, in what sequential order should the administrator execute the Flow elements?

  1. 1Execute a Get Records element to retrieve all expired Asset records related to the Account ID into a record collection variable.
  2. 2Pass the retrieved Asset record collection into a Loop element to process each Asset individually.
  3. 3Use an Assignment element inside the loop to update the Asset status field and add the current loop item to a secondary record collection variable.
  4. 4Place an Update Records element outside the loop to perform a single bulk DML update on the secondary record collection variable.
  5. 5Place a Create Records element outside the loop to generate a single follow-up Task record for the Account owner.

Answer

The correct sequence begins with retrieving the expired Asset records via a Get Records element, passing the collection into a Loop element, updating field values and adding records to a bulk collection via an Assignment element inside the loop, performing a single Update Records DML operation on the collection outside the loop, and finally creating the summary Task record outside the loop.
The correct order follows Salesforce Flow design best practices for bulkification. Data retrieval (Get Records) must occur first. Next, the collection is passed into a Loop element. Inside the loop, an Assignment element modifies field values in memory and appends the modified item to an output collection variable without executing DML. After the loop completes, a single Update Records element bulk-updates all Asset records at once. Finally, a Create Records element generates the summary Task.

Step-by-Step Solution

1
Query the target records using a Get Records element.
Stores all matching expired Asset records into a record collection variable.
Data must be retrieved from the database before it can be iterated or modified in memory.
2
Pass the collection variable to a Loop element.
Begins iteration over each individual Asset record in the collection.
Looping allows processing logic to be applied to each item sequentially.
3
Use an Assignment element inside the loop body.
Modifies record fields in memory and adds the updated loop item to a separate collection variable for bulk update.
Staging updates in memory prevents executing DML statements inside a loop, adhering to bulkification standards.
4
Place an Update Records element after the loop completes ('After Last Item').
Executes a single DML update statement for all modified Asset records in the collection.
Bulkifying DML outside the loop avoids hitting the SOQL/DML governor limit of 150 DML statements per transaction.
5
Execute a Create Records element outside the loop.
Creates a single Task record assigned to the Account owner.
Generates the required notification task after all Asset updates have successfully processed.

Key Concept

Bulkification in Flow Builder: Avoiding DML and SOQL elements inside loops
Rate this question