4

Lately I have came across an Error as given below.

Maximum number of duplicate updates in one batch (12 allowed). Attempt to update Id more than once in this Api call

I was able to solve the issue by re-creating the file with unique values. But I want to know the exact meaning/reason for this error. So My confusion is

When salesforce says that Maximum number of duplicate updates in one batch (12 allowed) Does it mean that,

  • its not allowed if I have 26 records in a file where I have 13 unique records and each one of them has 1 got duplicate records!?

  • its not allowed if I have 26 records in a file where 1 record is duplicated 13 times and rest of the 13 records in the file are unique.

3

I got a similar error when I was creating test data for a Unit Test. I tried inserting records who has a Process Builder Flow who updates their Parent's Field if a condition was met. I had more than 12 children per parent in my insert which caused this error.

My message to Salesforce....WOW! How silly! Their Process Builder is not bulkified IMHO. The Process Builder must run each record through the Process and collect any records for updating so it can do a bulk update at the end. However, instead of storing records for updating as a Map<Id, SObject> (which would let the last Parent win), they store the records as a SObject[] (which is still last record wins) and just add records as they go. Talk about asking for trouble.

An even better solution is to store records for update as Map<Id, SObject> and then as the Process Builder processes the batch, the Process Builder checks:

  • If records.get(record.Id) == null, put the record in the Map.
  • Then, for each Field to update: records.get(record.Id).put(field, value)

This would allow the last set Field per record to win (desirability is TBD).

0

It is both

I did a test by exporting 21 Account records.

  1. Copied the first one 13 times, got error on last 2 (14-2)

Maximum number of duplicate updates in one batch (12 allowed)

  1. Copied the 21 records and duplicate them, got errors on 9 of them (21-12)

Maximum number of duplicate updates in one batch (12 allowed)

SOAP Update

Fields whose names contain “Id” are either that object’s primary key (see ID Field Type ) or a foreign key (see Reference Field Type). Client applications cannot update primary keys, but they can update foreign keys. For example, a client application can update the OwnerId of an Account, because OwnerID is a foreign key that refers to the user who owns the account record. Use describeSObjects() to confirm whether the field can be updated.

This call checks a batch for duplicate Id values, and if there are duplicates, the first six are processed. For additional duplicate Id values, the SaveResult for those entries is marked with an error similar to the following:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.