Question

Difficulty: MediumFlow Builder Elements and Logic

A Salesforce Administrator is constructing an autolaunched flow to update a custom status field across a collection of inactive Partner Account records while strictly adhering to Salesforce governor limit best practices. Place the following flow execution steps in the correct order from first step to final step.

  1. 1Execute a Get Records element outside the loop to retrieve all inactive Partner Account records into a record collection variable.
  2. 2Pass the retrieved record collection into a Loop element to iterate through each Partner Account record.
  3. 3Use an Assignment element inside the loop to set the new field values on the current record variable from the loop.
  4. 4Use a second Assignment element inside the loop to add the updated current record variable to a separate output record collection variable.
  5. 5Execute an Update Records element outside the loop using the output record collection variable.

Answer

The correct execution order begins with executing a Get Records element to query the inactive Partner Account records into a collection variable, followed by iterating over the collection with a Loop element. Inside the loop, the first Assignment element modifies field values on the current loop item variable, and the second Assignment element adds that modified variable to a new output record collection variable. Finally, after the loop finishes, a single Update Records element executes on the output collection variable.
Salesforce design best practices require bulkifying flows by isolating database transactions (Get Records, Update Records) outside of loops. The process begins by retrieving records into a collection (Get Records), passing that collection into a Loop element, using an Assignment element to update the current record variable's fields, using another Assignment element to append the record variable to an output collection, and finally committing the output collection to the database using an Update Records element after the loop completes.

Step-by-Step Solution

1
Identify the data retrieval step.
Place the Get Records element first, outside of any loop structure.
SOQL queries must occur before looping to prevent executing data retrieval inside a loop, avoiding governor limits.
2
Initiate collection processing.
Place the Loop element second, receiving the record collection from the Get Records element.
Looping allows row-by-row processing of record items stored within the collection.
3
Modify the current record's field values.
Place the field value Assignment element as the first action inside the loop.
The temporary current item variable in the loop must have its field values set before it can be stored in the updated collection.
4
Stage the updated record into an output collection.
Place the collection Assignment element as the second action inside the loop.
Adding the modified item variable to a target output collection aggregates all updated records into a single collection variable.
5
Perform database commit.
Place the Update Records element last, connected to the 'After Last Item' path of the Loop element.
Executing DML once outside the loop commits all changes in bulk and consumes only one DML statement limit.

Key Concept

Bulkification and Flow Element Sequence
Rate this question