An administrator is building a Screen Flow that enables users to enter details for multiple new Contact records associated with a parent Account within a continuous entry loop. To avoid reaching database governor limits, all Contact records must be created in a single transaction after the user completes the loop. Which combination of Flow resources and elements should the administrator use to achieve this requirement?
- Populate a Record Single Variable inside the loop, add it to a Record Collection Variable using an Assignment element inside the loop, and place a single Create Records element after the loop referencing the collection variable.Answer
- BPopulate a Record Single Variable inside the loop, and place a Create Records element directly inside the loop to insert each record on every iteration.
- CAssign field values directly to a Get Records element inside the loop, and execute an Update Records element inside the loop for each Contact record.
- DExecute a Get Records element inside the loop to populate a Record Collection Variable on each iteration, then place an Update Records element after the loop without an Assignment element.
Answer
Populate a Record Single Variable inside the loop, add it to a Record Collection Variable using an Assignment element inside the loop, and place a single Create Records element after the loop referencing the collection variable.
The correct option adheres to Salesforce Flow design best practices for bulkification. By staging record values in a Record Single Variable, using an Assignment element to append that single variable to a Record Collection Variable during each iteration, and placing a single Create Records element outside the loop, the flow performs only one DML call regardless of how many records are generated.
Step-by-Step Solution
Key Concept
Bulkification of Flow DML operations using Record Collection Variables and Assignment elements