I am getting a duplicate rule issue with apex
first error: DUPLICATES_DETECTED, Use one of these records?: []
Now I want this rule to run, however, I need to get the details of the record that is being suggested by Salesforce duplicate management. How can I get the record details that is being suggested in Apex and show it as part of error message?
Let me know for any further details.!!
Thanks,
Best Answer
You can use DuplicateResult class to get duplicate records detected by duplicate rule.
Using
Database.SaveResult saveResult = Database.insert(contact, false);
get errors and successes. You may need to do few tweaks in code to get duplicate records.You can use
Datacloud.MatchResult
to get duplicate records. Please find the sample code.