1

I am trying to update a list of Contacts which is failing because of duplicate being detected. My duplicate rule field 'Action on Edit' and 'Action on Create' is set to Allow.

code:

        if(confirmedMatchesUpdates.size() > 0) {
            //Duplicate rules 'alert' on attempted insert of a duplicate
            try {
                update confirmedMatchesUpdates;
            }
            catch (DMLException e) {
                System.debug('retry!');
                update confirmedMatchesUpdates;
            }
        }
  • If you want to allow duplicate records to be created or edited then remove the rule in Duplicate Management and it will work. – Santanu Boral Jul 24 '18 at 7:46
  • @SantanuBoral I require the duplicate rule to be active and to also be able to update Contacts, even if duplicates are found in Contacts. Since the duplicate rule Action on Edit field is set to Allow, shouldn't it allow the update? – tom_12321 Jul 24 '18 at 7:50
  • The rule only runs on edited records when the edited fields are included in the associated matching rule. So what is your matching rule? – Santanu Boral Jul 24 '18 at 7:54
  • Yes, the rule runs and it sees there is a match based on the fields. I want that to happen, I want my code to see that duplicates are there but update the contacts anyway. – tom_12321 Jul 24 '18 at 8:00
  • did you select anything on "Operations on Edit" section? – Santanu Boral Jul 24 '18 at 8:02
0

The duplicate rule only runs on edited records when the edited fields are included in the associated matching rule.

If you don't select checkboxes for alert and report in Operations for Create and Operations for Edit section, then system will allow to create duplicate records.

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.