1

I'm designing a flow to roll up values to a parent record, and although I've reviewed the documentation here on bulkification, there is a piece that I haven't quite figured out.

The flow will run upon update of a child object (say, Opportunity), and update a value on its parent (say, Account). I understand that, once I get to the Update Records element, the interviews will wait and execute a single update call. What I don't clearly understand is, if multiple Opportunities trigger the flow in a mass update, and some relate to the same parent Account, will the list be de-duplicated? Or should I expect to encounter a duplicate IDs in list error?

If the latter, I would assume this is a use case that has to be solved via Apex instead, and there is not a way to de-duplicate the Accounts across flow interviews. Is this a known flow limitation?

1

1 Answer 1

1

Yes, many flows running at once and updating the same record can result in errors regarding too many updates to a single record. You can deduplicate the records by using an InvocableMethod, which is the only way flows can communicate with each other inside a single transaction. As a trivial example:

public class Input {
  @InvocableVariable public sObject record;
}

@InvocableMethod(description='Updates records' label='Update')
public static void doUpdates(Input[] requests) {
  Map<Id, sObject> values = new Map<Id, sObject>();
  for(Input request: requests) {
    values.put(request.record.Id, request.record);
  }
  update values.values();
}

Of course, I'm not including error handling, proper deduplication (e.g. handling which values should "win" in duplicates), etc, but this simple example should demonstrate that Apex can handle special scenarios that would otherwise fail in bulk flow operations.

1
  • Thanks for the quick answer @sfdcfox!
    – boop
    Commented Dec 6, 2023 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .