Sub topic 9
Sharing rules and conditions that limit a duplicate rule
This chapter assumes you can create a matching rule and a duplicate rule in Setup, and that you know how record visibility works through the org-wide default, roles and sharing rules. Two settings on a duplicate rule control which saves it checks and which existing records it compares against.
Record-level security: who can the rule see?
Every duplicate rule has a Record-Level Security setting. It decides whether the rule searches all records or only the ones the current user can see.
| Setting | What the rule compares against | Typical use |
|---|---|---|
| Enforce sharing rules | Only records the saving user can access | Teams that must not learn about each other's records |
| Bypass sharing rules | All records, regardless of access | Strict duplicate prevention across the whole org |
With Enforce sharing rules, a user who cannot see an existing "Acme Corporation" account will not be warned when they create a second one. The duplicate gets through because the rule never looked at the hidden record.
With Bypass sharing rules, the rule finds the hidden record. If the action is Block, the user cannot save, and they also cannot open the record that blocked them. Plan how those users will reach someone who can resolve the conflict.
Conditions: when does the rule run?
By default, a duplicate rule runs on every create and edit of its object. Conditions narrow that. When you add them, the rule runs only if the conditions are true at save time.
Conditions can test fields on the record being saved, such as Billing Country equals United States. They can also test attributes of the user doing the save, such as their profile. Common uses are:
- Apply a strict Block rule only to records in one region.
- Skip the rule for an integration user's profile, so a data load is not stopped.
- Run an expensive fuzzy rule only when a key field is filled in.
Conditions decide whether the rule runs at all. They do not change how records are matched. That is still the job of the matching rule.
How the checks combine
Common errors
- A duplicate was not caught. Check whether the existing record was visible to the user under Enforce sharing rules, and whether a condition made the rule skip the save.
- A user is blocked by a record they cannot find. This is the Bypass sharing rules setting working as designed.
- A rule never fires for a profile. A condition may exclude that profile. Review the conditions before editing the matching rule.
Exercise
A sales rep in the Europe team creates an account that matches one owned by the US team. The org-wide default for Account is Private. The duplicate rule is set to Enforce sharing rules, and the rep cannot see the US account. Is the rep warned? What change would produce a warning?
Show answer
The rep is not warned, because the rule only compares against records the rep can see. Changing the Record-Level Security setting to Bypass sharing rules lets the rule find the hidden account and apply its action. With a Block action, the rep would then be stopped without being able to open the matching record.