Question

Difficulty: MediumFlow Resources and Data Manipulation

Universal Containers needs an automated process that closes all open Task records associated with a custom Project object whenever the Project status changes to 'Completed'. Because a single Project record can have dozens of open tasks, the solution must handle the updates efficiently without exceeding SOQL or DML limits.

Which flow design pattern should the administrator use to update these related records?

  1. A
    Use a before-save record-triggered flow on the Project object to update the related Task records directly in the global $Record variable.
  2. Retrieve the related tasks into a collection, iterate over them in a Loop, assign updated field values to a new collection variable, and execute one Update Records element after the loop finishes.Answer
  3. C
    Query the tasks into a record collection, iterate through them with a Loop, and perform an Update Records operation within each iteration to commit changes immediately.
  4. D
    Loop through the related task IDs, invoke a Get Records element during each pass to fetch field values, update the fields, and save each record individually.

Answer

Retrieve the related tasks into a collection, iterate over them in a Loop, assign updated field values to a new collection variable, and execute one Update Records element after the loop finishes.
Bulkification in Salesforce Flow requires managing data manipulation outside of loops. The recommended pattern involves gathering records into a collection, updating field values across loop iterations into an output collection variable using Assignment elements, and executing a single Update Records DML element after the loop has concluded.

Step-by-Step Solution

1
Query the related records into a Record Collection Variable using a single Get Records element.
All open tasks associated with the project are retrieved in a single SOQL query.
Bulkifying data retrieval avoids running individual SOQL queries per record.
2
Iterate through the collection with a Loop element, update the Status field on the loop item, and add the item to an output Record Collection Variable using an Assignment element.
All record modifications are staged in memory without making database calls.
In-memory variable manipulation does not consume DML governor limits.
3
Place an Update Records element after the loop path completes, referencing the output Record Collection Variable.
All modified Task records are committed to the database in a single DML transaction.
Executing DML outside the loop adheres to Salesforce bulkification standards and prevents governor limit errors.

Key Concept

Flow bulkification, collection variables, and DML handling outside loop elements
Estimated Time:1m 15s
Rate this question