Sub topic 5
Building a custom matching rule
This chapter assumes you know how matching rules and duplicate rules work together. It also assumes you know the difference between exact and fuzzy matching, and that you can open Setup as an administrator.
When to build one
Standard matching rules cannot be edited. Build a custom rule when the standard logic misses your business case. For example, you may need to match Contacts on Email and Last Name, or compare a custom field such as an external customer ID.
Create the rule
- In Setup, search for Matching Rules and click New Rule.
- Choose the object, for example Contact.
- Enter a name, such as
Contact: Email and Last Name, and a description. - Add matching criteria. Each row pairs a field with a matching method.
- Set the matching equation if you need something other than the default.
- Save, then activate the rule.
Choose criteria
Each criterion is one field and one method. Exact works on most fields. Fuzzy methods are offered only for fields where the platform has a matching algorithm, such as names, company names, and addresses.
| Field | Method | Why |
|---|---|---|
| Exact | Two people rarely share an address. | |
| Last Name | Fuzzy: Last Name | Catches Smith and Smyth. |
| First Name | Fuzzy: First Name | Catches Jon and Jonathan. |
Set the equation and blank fields
By default, every criterion you add is combined with AND. To combine them differently, open the matching equation and use OR. For example:
(Fuzzy: Last Name AND Fuzzy: First Name) OR EmailTwo records match if they agree on both names, or if their email addresses are identical.
Each criterion has a Match Blank Fields option. When it is off, two empty values do not count as a match. When it is on, two empty values do count. Leave it off for fields that are often empty, such as Phone. Otherwise two records with no phone number will match on that field alone.
Activate the rule
A saved rule does nothing until you activate it. Activation is not instant, and the status shows Activating until the platform finishes indexing existing records. A duplicate rule cannot use the matching rule until activation completes. To edit an active rule, deactivate it first. That also means deactivating any duplicate rule that depends on it.
Common errors
- The rule never matches. A fuzzy method was chosen for a field that holds codes or IDs. Use Exact instead.
- Too many false matches. Match Blank Fields is on for an optional field. Turn it off.
- The rule is missing from the duplicate rule's picker. It is still Activating, or it is inactive.
Exercise
You built a Contact matching rule with Email (Exact) and Phone (Exact), with Match Blank Fields on for both. Two contacts have different emails but both have an empty Phone. Why might the rule flag them, and what is the fix?
Show answer
With Match Blank Fields on, the two empty Phone values count as a match. If the equation uses OR, or if Phone is the only criterion that decides the result, the contacts are flagged even though nothing real matches. Turn off Match Blank Fields for Phone, deactivate the rule first if it is active, then reactivate it.