Exploring and customizing rules
In this section, we will learn how to customize the duplicate and matching rules.
Customizing duplicate rules
As we have already seen in the previous sections, duplicate rules are used to alert on potential duplicates or prevent potential duplicates for a given record (if it is used on objects other than Account, Contact, and Lead, the Potential Duplicates component cannot alert the user in real time, but the Duplicate Record Set object will be created anyway).
To create a new duplicate rule, jump to Setup | Duplicate Management | Duplicate Rules and click the New Rule | Contact button. Select the object you want the rule to be created on:
Duplicate rule creation
Before creating everything, let’s design our scenario. We have a custom object called External Contact that comes from an external system and represents thousands of contacts on an external system that the business guys decided not to migrate into Contacts (because there is too much data inconsistency). But despite this, this table should be used when creating new contacts on the system to enrich data.
This object holds the following custom fields:
- First Name (text, 80)
- Last Name (text, 80)
- Company (text, 80)
- Email (email type)
- Phone (phone type)
Let’s also create a new tab and add it to our app (and create our first record manually):
Custom object to handle external contact data
Let’s go back to the Duplicate Rule Edit creation page. We have already seen how these sections work:
Custom duplicate rule creation
The section below Actions, not shown in the previous screenshot, is about matching rule selection. We haven’t created a custom matching rule yet, so leave this section empty (it will be populated with one of the standard matching rules on the Contact object (we’ll get there shortly).
The last section is called Conditions and it can be used to select specific conditions on the record that should be checked (for example, conditions on fields of the contact, account or current user records). Hit Save to save the new rule (if it is not yet active).
If we want to reorder the rules on the same object, click on the Reorder link on the rule page and select the required order:
Duplicate rule sorting on the same object
If a match is found on the first rule, the second one is not evaluated at all.