0

We have a Duplicate Rule defined on Contact Object.

The requirement is to insert or update Contact records in Batch apex. Ideally, if any duplicate is found I should get Duplicate Error in apex.

While implementing this use case, I have seen a weird behavior that when execute method is called for 1st set of Contacts, I am able to insert duplicate contacts with no errors, ideally it should error out and when execute method is called for 2nd set of Contacts then I am seeing duplicate contact error if any duplicate is found.

Why would apex not show Duplicate Error while inserting Duplicate contacts?

When I try from UI, I get proper Duplicate error message.

Any Help?

  • Ohh, yea it did help, Thank you so much. But just wondering why would salesforce do that? It should fire even in case of bulk insert also right? – sfdc07 Sep 8 at 10:12
  • Ideally, it should, but I honestly don't know why Salesforce chose to have it this way and couldn't find much documentation on the same. – arut Sep 8 at 10:19
  • Got you... Appreciate your help..!! Thank you..!! – sfdc07 Sep 8 at 10:23

Your Answer

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

Browse other questions tagged or ask your own question.