function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ALAL 

Flow Error - maximum number of duplicate updates in one batch (12 allowed)

Hello, I have a flow that loops through assets on an account. When I try to do a mass update manually from an asset list view, I get the 'maximum number of duplicate updates in one batch (12 allowed)' when updating more than 12 assets on an account. 

In the flow I have a loop element, and any items that meet certain criteria are directed to the update element. The update elemnt is where I receive the error whenever I update more than 12 records on the same account. 

Is there a way to bulkify this? Would I need an apex trigger in addition to this flow? Thank you.  
NagendraNagendra (Salesforce Developers) 
Hi,

Sorry for this issue you are facing.

May I suggest you please check with below link from the stack exchange community with a similar discussion which might help you further. Please let us know if this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
ALAL
Hi Nagendra, thank you for sending this link, I'm wondering do I need to replace the flow with an apex trigger and class, or can I bulkify the flow?

From some of the articles I've seen, I can have a loop element, then create an assignment element, and then the update element. This is what I'm currently trying to do, but I'm still hitting the maximum number of duplicate updates in one batch (12 allowed) limit. 
Cherisse Taylor 11Cherisse Taylor 11
I am running into the same issue.  Al, have you found a solution yet?
ALAL
Hi Cherisse, 

I'm still working on a solution. I deactivated my flow and process builder action. From there, I'm trying to create an after update/after insert trigger to do the same function but with bulkification. 

In my case I'm looking to iterate through assets, and depending upon certain conditions, update that asset's account. 
Sebastian Davis 9Sebastian Davis 9

All,
This "Maximum number of duplicate updates in one batch" is due to updating the same record more than 12 times in one batch.

Example:
If you have a process builder process that updates a parent Account with a datetime stamp when a Contact is changed to Active, then you run an update with dataloader or have a flow (or any other means of bulk updating Contacts including mass list view edits) that updates Contacts to Active, this is a configuration that is at risk for causing the "Maximum number of duplicate updates in one batch" error.

All it would take is updating 13 Contacts at once to Active under one Account. To mitigate this risk you need to find what is causing the recursive updates and add some type of logic that will stop it from making the same update over and over. 

In the example above you could add additional criteria tto the process builder process that would only update datetime field on the parent Account once.

Example criteria you could add for this example use case: 

OR(
       
ISBLANK(Account_Datetime_Field__c), 

       NOW() > (Account_Datetime_Field__c + (1/24))
)

 This would update it when it's blank or if it has been more than 1 hour since the last time it was updated, effectively mitigating the error by avoiding updating it again in the event it was just updated.

That way, when you update 13 child Contacts to Active at once, it would update the datetime field once for all of the child contact updates. 

I also have to mention, that you should never put an Update Record element inside a loop in a flow (same best practice in apex, no DML in a for or while loop). Instead, use an Assign Element that adds a record to update to a record collection variable. Once the loop is finished, you would have 1 Update Records element that updates the collection of records at once.