TL;DR: Check out code to enrich DuplicateRecordItem records and to handle extra DuplicateRecordSet records after merging duplicates at https://github.com/dschach/duplicatehandling
I love the standard Salesforce duplicate records feature (Trailhead: https://trailhead.salesforce.com/content/learn/modules/sales_admin_duplicate_management H&T: https://help.salesforce.com/s/articleView?id=sf.managing_duplicates_overview.htm) and have used it extensively, both to prevent duplicates and to track/report on duplicates for later management.
If your org is set to allow duplicates to be created and to report on them, then you’ve probably gone to the Duplicate Record Set tab and looked at the sets there, used a report to see all the sets, or clicked on the “Possible Duplicates” component on a record page.
Reporting & Duplicate Record Item Enrichment
Unfortunately, reporting on Duplicate Record Items is difficult because it doesn’t show enough detail about the duplicates themselves. If you want to group by any attribute other than the record name or Duplicate Rule, you’re out of luck. Wouldn’t it be nice to have some code to enrich your Duplicate Record Item object to include a proper lookup to the records so you can make custom report types to include, say, the Record Type or the Contact Email?
I’ve created an easily-installable bit of Apex that you can put into your sandbox and promote to Production, and you can give it a test-run in a scratch org if you’d like.
Unnecessary Duplicate Record Set Auto-Deletion
Once you’ve chosen to merge those duplicates, then good job! You’ve removed some clutter from, say, the Contact object… but you may inadvertently have left some clutter on the Duplicate Record Set and Duplicate Record Item object!
Though you started with one DR Set and two DR Items, and you merged the two Contacts, Salesforce doesn’t clean up the no-longer-needed Set/Item combo. So I wrote some code that removes that single, lonely, unnecessary set. After all, you’ve done a good job, so why shouldn’t you be rewarded with the removal of that reminder of once-dirty data? This code fixes that!
Head over to https://github.com/dschach/duplicatehandling and give it a whirl! Instructions are in the README, and full code documentation is at https://dschach.github.io/duplicatehandling/.
Share Your Thoughts