Customizing matching rules
A matching rule defines how duplicate records are identified. We have predefined standard matching rules, but we can create new matching rules by going to Setup | Duplicate Management | Matching Rules and clicking on New Rule. Select the External Contact object.
Let’s create a rule with the following configuration:
Matching rule creation
The Matching Criteria section states which conditions should trigger the potential duplicate match. Matching methods define the algorithm used to compare values and can be set to Exact to be triggered only if we have the same value or Fuzzy: type to provide specific data type algorithms (match for first/last names, company, and so on). Select the Match Blank Fields if blank field matching can be a valid filter. Activate the matching rule with the Activate button.
For a deeper understanding of matching methods, refer to Salesforce Help at https://help.salesforce.com/articleView?id=matching_rules_matching_methods.htm&type=5 and https://help.salesforce.com/articleView?id=matching_rules_matching_algorithms.htm&type=5.
Let’s go back to the duplicate rule in the external contacts we created in the previous section, edit it, and compile the Matching Rules section (you can add more than one rule) and select your brand new matching rule:
Matching rule selection on a duplicate rule
The last thing to do is map the fields to the custom External Contact Field object so the algorithm can properly match records. Click on the Mapping Not Selected link next to the small warning icon:
Mapping selection on duplicate rule
Save the rule and click on the Activate button.
Now let’s create a new contact record with the same First Name, Last Name, and Email of the external contact we created earlier:
Duplicate rule running on custom object
The only difference is that once we save the contact record and click on the View Duplicates link on the potential duplicates component, we cannot merge records as they are different objects:
Duplicates found on custom object
Now we can use the external contact fields to enrich our new contact, and then delete the record once the data has been manually merged (this is just an example that doesn’t have the best user experience, but it gives your fantasy a boost!).
This is only a simple way to implement cross-object duplicate rules; you can define any kind of duplicate rules with custom objects. The only limitation is that the Potential Duplicates component will only work with Account, Contact, and Lead objects; to have a look at all duplicates for a custom object, use duplicate jobs instead.