DUPLICATES_DETECTED: meaning and how to fix it
Quick answer
DUPLICATES_DETECTED: An active duplicate rule with the Block action found a likely duplicate of the record you are saving. The Allow action with an alert can be overridden by the caller. Start with: Open the matching records named in the error and update one of them instead.
Typical message: DUPLICATES_DETECTED, Use one of these records?
Cause
An active duplicate rule with the Block action found a likely duplicate of the record you are saving. The Allow action with an alert can be overridden by the caller.
How to fix DUPLICATES_DETECTED
- Open the matching records named in the error and update one of them instead.
- If the rule action is Allow with an alert, saving through Apex can set the duplicate rule header to allow the save.
- Review the matching rule if it blocks legitimate records.
Database.DMLOptions dml = new Database.DMLOptions();
dml.DuplicateRuleHeader.allowSave = true;
Database.insert(acc, dml); Have a different message? Paste it into the error decoder, which matches it against 45 common Salesforce errors in your browser.
Frequently asked questions
What does DUPLICATES_DETECTED mean in Salesforce?
An active duplicate rule with the Block action found a likely duplicate of the record you are saving. The Allow action with an alert can be overridden by the caller.
How do I fix DUPLICATES_DETECTED?
1. Open the matching records named in the error and update one of them instead. 2. If the rule action is Allow with an alert, saving through Apex can set the duplicate rule header to allow the save. 3. Review the matching rule if it blocks legitimate records.
More Data and DML errors
SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Message text varies slightly by release and context, so confirm against the official page before relying on it.