Salesforce provides a slick way to identify duplicates and merge them using Duplicate Rules and Matching Rules. When you create or edit a record that triggers the rule, a Duplicate Record Set record is created with at least 2 related Duplicate Record Set Item records. The Duplicate Record Set Item records represent the duplicate records that triggered the rule and the Duplicate Record Set record is the parent record. When you merge the Duplicate Record Set Item records through the merge process, the Duplicate Record Set (parent) record does not get deleted and you have to do a mass delete in order to clean up your org.
Tired of mass deleting your Duplicate Record Set records after you merge your duplicate records? We have created a free, unmanaged AppExchange package to take care of this immediately after you merge the Lead, Contact or Account records.
The package contains the following components:
- Duplicate Record Set | Delete Duplicate Record Items (Process Builder)
- Delete Duplicate Record Set Record (Autolaunched Flow)
- Duplicate Record Set w/ Related Duplicate Items (Report Type)
How to Configure the App:
- Install the AppExchange Package into a sandbox environment.
- Go to Setup | Flows and find the flow called Delete Duplicate Record Set Record.
- Click Activate.
- Go to Setup | Process Builder and click the process called Duplicate Record Set | Delete Duplicate Record Items.
- Click Activate.
That’s it, you are ready to start testing!
How It Works:
- The process builder criteria is looking for the RecordCount field to have a value less than or equal to 1. The RecordCount field is a standard roll up summary field on the Duplicate Record Set record that is counting the # of related Duplicate Record Set Items.
- When the above criteria is true, the process invokes the flow which is super simple. It contains a single delete element which deletes the Duplicate Record Set that started the process.