Sub topic 2
Building a Custom Matching Rule
This chapter assumes you understand Salesforce objects, fields, and records, and can navigate Setup. A matching rule defines when two records look alike. A duplicate rule uses that result to decide what users can do.
Build the matching rule
In Setup, open Matching Rules, select the target object, and create a custom rule. Add matching criteria by choosing fields and methods such as Exact or Fuzzy. For example, a Contact rule might compare:
| Field | Method | Purpose |
|---|---|---|
| Exact | Finds the same email address | |
| Last Name | Fuzzy | Finds spelling variations |
Use fields that identify the same real-world record. A rule comparing only LastName will produce many false positives.
Matching equations, conditions, and blank fields
The matching equation is the combination of field comparisons that must succeed. An equation using Email and Last Name is more selective than one using either field alone. Choose the logic that reflects your business identity rules.
Matching methods normalize or compare values differently. Exact matching can still handle some Salesforce normalization, while fuzzy matching can recognize likely variations. Test real examples before activating the rule.
Treat blank fields carefully. A blank email should not identify every record with a blank email. Exclude records with missing identifying data through conditions where possible, and test whether blank values produce the results your organization expects.
Connect it to a duplicate rule
Create a duplicate rule for the same object and select the matching rule. Set when it runs:
- On create, when users make new records.
- On edit, when users change existing records.
A duplicate rule can also use conditions, such as applying only to active Accounts or only when a key field is populated.
Choose an action
- Allow lets the save continue.
- Alert allows the save but warns the user and shows possible matches.
- Block prevents the save until the user changes or cancels it.
- Report is a review approach, not usually a save action. Use duplicate record sets and reports to examine possible duplicates after detection.
Sharing and scope
Record-level security affects which records Salesforce can compare when the rule uses sharing settings. A broader comparison can find duplicates users cannot normally view, but it requires careful security review. Conditions also limit which records the rule evaluates. Start narrowly, test with representative users, and expand only when the results are trustworthy.
Exercise
You need to warn users about possible duplicate Contacts but still let them save. Which action should you choose?
Show answer
Choose Alert for the duplicate rule’s create or edit action. The save continues, and Salesforce displays the possible matches.