Soru

Zorluk: OrtaFlow Builder Elements and Logic

A Salesforce Administrator needs to design an autolaunched flow that updates the Status field of all active Contact records associated with an Account whenever the Account's Status changes to 'Inactive'. The solution must process multiple child records efficiently without exceeding system governor limits. How should the administrator construct the flow logic?

  1. Query related active Contacts with a Get Records element, loop through the collection, update each record's Status field in an Assignment element while adding it to a new collection variable, and execute a single Update Records element on the collection after the loop.Cevap
  2. B
    Query related active Contacts with a Get Records element, loop through the collection, and place an Update Records element inside the loop to save changes to each Contact individually.
  3. C
    Create a Roll-Up Summary field on the Account to fetch and update child Contact statuses directly without using collection variables or loop structures.
  4. D
    Loop through the child Contacts and use a Decision element to assign picklist values directly without adding the modified records to a record collection variable.

Cevap

Query related active Contacts with a Get Records element, loop through the collection, update each record's Status field in an Assignment element while adding it to a new collection variable, and execute a single Update Records element on the collection after the loop.
The correct approach bulkifies flow operations by gathering updated child records into a record collection variable using Assignment elements inside the loop, followed by a single Update Records element after the loop completes. This pattern ensures that database operations are minimized, adhering to Salesforce governor limits.

Adım Adım Çözüm

1
Retrieve related child records
Obtain a collection variable containing active Contacts for the Account using one Get Records element outside the loop.
Retrieving all records in a single query avoids executing SOQL queries inside a loop.
2
Process records in memory using a Loop and Assignment elements
Iterate through each Contact record, update its Status field, and add the updated record to a target collection variable.
Assignment elements modify record variables in memory without invoking database transactions or consuming DML limits.
3
Persist changes using a single DML operation
Pass the modified collection variable into a single Update Records element located after the loop ends.
Executing database operations outside the loop ensures the flow bulkifies correctly and respects Salesforce governor limits.

Anahtar Kavram

Flow Bulkification and Collection Processing
Bu soruyu puanla