1

We have been using a Flow to update custom fields on a Lead after a Task is completed. These Tasks are phone calls that are being logged through the RingCentral for Salesforce App. Below is an image of the Flow and where the error is occurring. Does anyone know why we are going past the number of 12 duplicate updates allowed? The flow is triggered from the Task record when it is created or updated based on two conditions 1- TaskSubtype = Call 2- IsClosed = True. Thank you!

enter image description here

enter image description here

10
  • 1
    Does this answer your question? Roll-up summary field using PB + Flow
    – identigral
    Commented Jul 14, 2022 at 20:33
  • @identigral - I'm not sure. The flow is designed to update 3 fields on the Lead record by the values of 3 fields on the latest Task record. I'm not sure how this is causing the attempt to update the lead record more than 12 times at once Commented Jul 14, 2022 at 20:41
  • It's not quite the same but the answer is on point - your flow is doing an update in the same transaction, thus the error. It's unclear to us whether this can be untangled by changing the Flow to use a variable + collection or it has to be Apex as the linked answer suggests.
    – identigral
    Commented Jul 14, 2022 at 20:52
  • I don't recall ever seeing this error, but reading the details of the error message, it seems that this one Lead is attempting to be updated 12 times in the same transaction. It sounds to me like a recursion issue. Is this Flow triggered on the Lead? If not, if it is triggered on the Task, do you have another trigger that updates the Task upon update of the Lead, which would then cause this Flow to run again to update the Lead, ad infinitum? Remember, all of these consecutive triggering updates will run under one execution context.
    – Moonpie
    Commented Jul 14, 2022 at 20:59
  • 1
    @Moonpie For future reference, the error specifically occurs when a record in the same DML list occurs more than 12 times. You can update a single record dozens of times, even recursively, assuming you don't break the 16 depth DML recursion limit, in the same transaction, but not in the same DML operation.
    – sfdcfox
    Commented Jul 15, 2022 at 9:00

1 Answer 1

2

This error specifically occurs when the same Id appears in a DML list more than 12 times. In Apex, imagine you had the following logic:

Lead[] updates = new Lead[0];
Lead sampleLead = [SELECT Id FROM Lead WHERE IsConverted = false LIMIT 1];
for(Integer i = 0; i < 20; i++) {
  updates.add(new Lead(Id=sampleLead.Id));
}
update updates; // System.ListException: Duplicate id in list: 00Q1T00001cWpxKUAS

It appears, therefore, that RingCentral is loading many tasks at once for the same Lead in the same transaction, thus causing this error. Unfortunately, due to the nature of flow bulkification, there's no way to detect this problem at the flow level.

Your alternatives would be to (a) use an Apex action to detect duplicates and somehow manage them, (b) use an Apex trigger, or (c) configure your integration to limit itself to 10 task records at a time, if possible.

Also, general feedback on your flow: it is performing more DML operations than it needs to. Each of those Update Record elements should be Assignment elements, with one Update Record element at the end. This allows the flow bulkification to be more efficient. I don't think it will solve your current problem, but it may help with issues in the future.

Use DML only once example

1
  • This is exactly the answer I need. I can at least go back to my boss and let him know what is going on. Thank you so much! Commented Jul 16, 2022 at 4:05

You must log in to answer this question.

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