Sub topic 11
Activating, editing and ordering rules
This chapter assumes you can create a matching rule and a duplicate rule in Setup, and that you know what each one does. It covers how the two kinds of rule change state, why edits need care, and how several rules on one object interact.
Matching rules must be active first
A duplicate rule points to one or more matching rules. Salesforce will not let you activate the duplicate rule until every matching rule it uses is active. A new matching rule starts as inactive. When you activate it, Salesforce indexes the existing records for that object, so the status shows Activating before it shows Active. On a large object this can take a while.
While a matching rule is still activating, a duplicate rule that depends on it cannot be activated. Wait for the status to reach Active.
Editing an active rule
You cannot change the matching criteria of an active matching rule. The usual sequence is:
- Deactivate every duplicate rule that uses the matching rule.
- Deactivate the matching rule.
- Edit the matching equation or field conditions.
- Activate the matching rule and wait for Active.
- Reactivate the duplicate rules.
While the duplicate rules are off, nothing checks new or edited records on that object. Plan the change for a quiet period. Test it in a sandbox first.
Changed rules only affect records saved afterward. Salesforce does not re-check records already in the org. Duplicates that were saved earlier stay until you find and merge them.
Ordering several duplicate rules
An object can have more than one active duplicate rule, up to a fixed limit per object. Typical examples are one rule that blocks exact email matches and one that only alerts on fuzzy name matches. On the object's Duplicate Rules page you can drag the rules into order. Salesforce runs them in that order, so the order decides which rule's alert or block message a user sees first.
Put the strictest rule first. A Block rule placed after a looser Alert rule can be hard to reason about, because users may react to the first message and never reach the second.
| Task | Requirement |
|---|---|
| Activate a duplicate rule | All its matching rules are Active |
| Change matching criteria | Matching rule is deactivated first |
| Deactivate a matching rule | No active duplicate rule uses it |
| Change which message appears first | Reorder the duplicate rules |
Deactivate or delete
Prefer deactivating over deleting. A deactivated rule keeps its configuration, so you can turn it back on. Deletion removes it for good.
Exercise
You need to add a second field to an active matching rule that an active duplicate rule uses. List the steps in order, and say what happens to records saved before the change.
Show answer
Deactivate the duplicate rule, then deactivate the matching rule, edit the matching equation, activate the matching rule and wait for it to reach Active, then reactivate the duplicate rule. Records saved before the change are not re-checked, so existing duplicates remain until someone finds and merges them.