Question

Difficulty: HardFlow Builder Elements and Logic

An administrator is designing an autolaunched flow to process a list of active Account records and create a follow-up Task for each Account's primary Contact. The flow will handle batch operations involving hundreds of records simultaneously. Which design pattern should the administrator implement within Flow Builder to successfully process all records without violating governor limits?

  1. Iterate through the Account collection using a Loop element, populate individual Task record variables, add each Task variable to a Task collection variable using an Assignment element inside the loop, and place a single Create Records element after the loop.Answer
  2. B
    Iterate through the Account collection using a Loop element, use a Get Records element inside the loop to query the primary Contact, and create the Task record immediately using a Create Records element inside the loop.
  3. C
    Iterate through the Account collection using a Loop element, populate a single Task record variable, and execute a Create Records element at the end of each loop iteration.
  4. D
    Iterate through the Account collection using a Loop element, aggregate child Contact counts using a Roll-Up Summary Assignment element inside the loop, and update each Account using an Update Records element inside the loop.

Answer

Iterate through the Account collection using a Loop element, populate individual Task record variables, add each Task variable to a Task collection variable using an Assignment element inside the loop, and place a single Create Records element after the loop.
The correct approach for bulkifying flows involves staging record updates or creations in a collection variable inside the loop using an Assignment element, followed by executing a single Create Records element outside of the loop. This consumes only 1 DML operation regardless of the number of records processed.

Step-by-Step Solution

1
Iterate over the incoming collection of Account records using a Loop element.
Each Account record is processed individually per iteration.
Allows inspection and mapping of fields for individual items in the collection.
2
Assign task field values to a record variable and add that record variable to a Task record collection variable using an Assignment element within the loop.
The Task collection accumulates all new records without executing database transactions inside the loop.
Staging records in a collection in memory avoids executing DML statements inside the loop.
3
Connect the 'After Last' path of the Loop element to a single Create Records element targeting the Task collection variable.
All staged Task records are inserted in a single bulkified DML operation.
Executes 1 DML statement for the entire collection, adhering to Salesforce governor limits.

Key Concept

Bulkification in Flow Builder using collection variables and placing DML elements outside loops
Rate this question