Question

Difficulty: MediumFlow Resources and Data Manipulation

An administrator is configuring a flow to update the status of multiple child Invoice Line Item records to 'Voided' whenever a parent Invoice is cancelled. To ensure data manipulation operations adhere to governor limits and Salesforce best practices for flow resources, what is the correct sequential order to configure the Flow Builder elements?

  1. 1Query and retrieve all related Invoice Line Item records into a record collection variable using a Get Records element.
  2. 2Iterate through the retrieved record collection variable using a Loop element.
  3. 3Set the Status field to 'Voided' on the current loop item variable using an Assignment element.
  4. 4Add the modified loop item variable to a new record collection variable using an Assignment element.
  5. 5Commit all updates to the database with a single Update Records element pointing to the new collection variable outside the loop.

Answer

Query records with Get Records, loop over the collection, assign field values to the current item, add the current item to a new collection, and perform a single Update Records element on the new collection outside the loop.
The correct pattern follows standard bulkification principles in Flow Builder: first retrieve data with Get Records, iterate through the collection with a Loop, modify fields in memory using an Assignment element, stage the modified record into a secondary collection variable with another Assignment element, and finally commit the entire collection via an Update Records element after the loop path completes.

Step-by-Step Solution

1
Retrieve child records using Get Records
A record collection variable containing all related Invoice Line Items is populated.
Data must be queried from Salesforce before iterative logic or field changes can take place.
2
Pass the collection into a Loop element
The flow begins iterating through each Invoice Line Item one by one.
A loop is required to expose individual record fields for modification.
3
Update field values on the loop variable using Assignment
The current item variable has its Status field modified to 'Voided' in memory.
Field changes must be made to the local record variable prior to collection staging.
4
Append the modified record to an update collection variable using Assignment
The updated record is added to a list of records awaiting a bulk DML update.
Collecting records in memory prevents executing individual DML operations inside the loop.
5
Execute Update Records on the update collection variable after the loop
All modified records are saved to the database in a single DML operation.
Performing DML operations outside the loop ensures the flow is bulkified and does not exceed transaction governor limits.

Key Concept

Bulkified Flow Data Manipulation and Collection Resources
Estimated Time:1m 30s
Rate this question