Monitoring and preventing duplicate records is a fundamental need for Salesforce admins. So, it’s no surprise that duplicate management was one of the top 5 ideas of all time on the Salesforce IdeaExchange, earning a whopping 67,260 points.
Despite Salesforce’s delivering on this request in the Spring ’15 release, many admins still turn to paid third party tools to manage duplicates. But, having leveraged this functionality for several major projects, including our own lead routing tool, we believe there is a strong case for using Salesforce’s native duplicate management.
Given that you’re already paying for duplicate management in Salesforce, there’s no compelling reason to invest in a custom or third party application. Learning how to use this native functionality in Salesforce will save you time and money, relieve strain on your system, and allow you to apply duplicate management to unique use cases using custom Apex, flows, and clicks.
Setting Up Duplicate Management
There are two basic components you’ll need to configure to manage duplicates in Salesforce: matching rules and duplicate rules.
Step 1: Set Up Matching Rules
Matching rules are configured first and are applied to the object you want to match against. Matching criteria determines which fields you want to compare, and how you want to do it. Common matching criteria includes fields like account name, email, contact email address, or a combination of these. Matching criteria can also be based on a combination of fuzzy operators, which comes in handy for processes like lead-to-account matching (check out this resource for more details on fuzzy operators).
Step 2: Set Up Duplicate Rules
Next, you’ll create a duplicate rule on an object. A duplicate rule allows you to invoke the matching rule(s) you’ve configured. A traditional duplicate rule is usually applied to something like a contact email address, so that when the email address field is populated or changed, it is then checked against other contacts in the system.
Duplicate rules work across multiple objects and can match against any object in the system. This is what gives native duplicate management much of its power. For example, a duplicate rule on a lead can check the matching rule on a contact (or on any other standard or custom object).
Taking Action on Duplicates
There are three ways to take action on duplicates identified in Salesforce: blocking, alerting, and reporting. You can configure these actions to take place upon the creation of a record and/or when a record is edited.
Blocking is your first line of defense for duplicates. This blocks the user from saving a duplicate record, with no ability to override. This method is recommended for hard and fast duplicate rules that don’t require review.
The second option is alerting. Alerting issues an error message to the user, which they can choose to override with a click. Note: be cautious in how you apply alerting. Because alerts happen behind the scenes via the API, this method can cause API integrations to fail.
The final option is reporting, which creates duplicate records sets and duplicate record items that can then be reported on. This method takes place behind the scenes, and is not seen by the user. Reporting can function as a passive monitoring system for duplicate management, and is best applied when working with more relaxed or non-traditional duplicate rules.
Monitoring Duplicates with Reporting Data
To monitor duplicates identified via reporting, you’ll need to set up two custom report types.
The “duplicate record sets and items” report type will tell you the number of records that meet a particular duplicate rule. You can then click into these rules and view the record sets. But you won’t see any fields or information about what Salesforce has matched.
Secondly, you can create custom reports for accounts/contacts/leads (or other objects) with duplicate record items. This report type allows you to see the specific fields that are duplicates of each other. You can then take action or share the report with users to determine whether action is needed.
Eliminating Duplicates Manually
Duplicates identified with reporting data are typically handled in a couple of ways.
In Lightning (and only in Lightning) there is a “Compare and Merge” option on the duplicate record set. This function will compare and merge all of the duplicates within the set at the click of a button.
You can also initiate a merge from the find duplicates component on the lead or contact. This component shows a list of potential duplicates on the object layout, which users can then select and merge manually. Note: This component functions only based on the reported data. It will identify duplicates based on what you have configured, and only from that point forward (not historically).
Extending Duplicate Management in Apex
We’ve talked about how you can invoke duplicate management via the duplicate rule itself at the user level. But you can also call duplicate management from Apex via match methods, which allows you to extend this functionality.
For example, Lane Four’s lead-to-account matching product is built on this functionality. When a user creates or edits a lead, Lane Four calls match methods, and Salesforce provides a table of what it has matched. Lane Four then parses and takes intelligent action based on these matches.
You can also create merge scripts that take the duplicate record sets and duplicate record items created by duplicate management and merge the records. Historically, it’s been hard to create merge scripts because flagging the dupes has been very difficult. But now duplicates are more easily identified, making mass merge scripts a viable option.