[SalesForce] Getting error: ‘Update Failed… DUPLICATES_DETECTED’ even with duplicate rule set to ‘Allow’

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;
            }
        }

Best Answer

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.

Related Topic