Question

Difficulty: HardFlow Builder Elements and Logic

A Salesforce Administrator is designing an autlaunched Flow to bulk-process and close all open Work Orders linked to a deactivated Parent Asset while avoiding governor limits. Arrange the Flow Builder elements in the correct execution order required to properly query, process in memory, and commit the database updates.

  1. 1Execute a Get Records element to retrieve all open Work Order records associated with the Parent Asset ID.
  2. 2Enter a Loop element to iterate through the collection of retrieved Work Order records one by one.
  3. 3Execute an Assignment element inside the loop to set the Status field on the current loop record to 'Closed'.
  4. 4Execute an Assignment element inside the loop to add the modified current loop record to a new Record Collection variable.
  5. 5Execute an Update Records element after the loop finishes, passing the new Record Collection variable to update the database.

Answer

The correct execution sequence is: (1) Retrieve open Work Orders using a Get Records element, (2) Pass the record collection into a Loop element, (3) Use an Assignment element inside the loop to update the current item's Status field, (4) Use a second Assignment element inside the loop to append the updated item to a Record Collection variable, and (5) Place an Update Records element outside the loop using the Record Collection variable to bulk commit the changes.
The correct order follows standard Salesforce bulkification design patterns: query records first using Get Records, open a Loop, perform field-level updates in memory using Assignment, append the item to a record collection via Assignment, and execute a single Update Records DML statement after the loop completes.

Step-by-Step Solution

1
Identify the data retrieval step.
Get Records is placed first to fetch all target Work Order records.
Flows cannot process records in memory without first retrieving them from the database.
2
Identify the iteration step.
The collection output from Get Records feeds directly into a Loop element.
Loop elements process items within a collection sequentially.
3
Identify the field value assignment step within the loop.
An Assignment element modifies the current loop item's Status field.
Field changes must be defined in memory for the current item before adding it to a staging collection.
4
Identify the collection staging step within the loop.
A second Assignment element adds the updated loop item to a separate Record Collection variable.
Staging records in a collection variable enables bulk DML operations.
5
Identify the bulk database commit step.
An Update Records element executes on the 'After Last Item' path of the Loop.
Placing DML elements outside loops avoids hitting the SOQL/DML governor limit of 150 DML statements per transaction.

Key Concept

Bulkification and Flow Element Sequencing
Rate this question