How do matching and duplicate rules protect data integrity in Sales Cloud databases?
Answer
Basics: Duplicate leads, contacts and accounts cause double outreach, bad reporting and merge work. Duplicate Management stops them at entry, rather than cleaning up later.
How it works: 1) Setup > Matching Rules: use a standard rule (Standard Account/Contact/Lead Rule) or create one with field comparisons (exact, fuzzy, with blank handling). Activate it. 2) Setup > Duplicate Rules: choose the object, select matching rule(s), set actions on Create and Edit (Allow or Block, Alert text, Report), and choose whether to enforce sharing rules or bypass them. 3) When a user saves, the rule runs after validation rules in the save order; matches show a banner or block the save. 4) Matches are logged in Duplicate Record Sets and Duplicate Record Items if Report is selected.
Advanced / deep dive: Fuzzy matching handles typos and nicknames, but some fuzzy methods consume more processing. Bypassing sharing lets a rep be warned about records they cannot see (useful, but leaks existence), while enforcing sharing misses hidden duplicates. Rules apply to API loads too: with an Allow-with-alert rule, API saves fail unless the caller passes the duplicate rule header; Apex uses Database.DMLOptions.DuplicateRuleHeader.allowSave. Datacloud.FindDuplicates.findDuplicates(records) lets Apex check without saving. Existing data is cleaned with Duplicate Jobs (higher editions only; verify edition) and merge. Per-object limits exist (commonly documented as five active duplicate rules and five active matching rules per object).
Code / config example:
Database.DMLOptions opts = new Database.DMLOptions();
opts.DuplicateRuleHeader.allowSave = ;
List<Database.SaveResult> res = Database.insert(newLeads, opts);
(Database.SaveResult r : res) {
(!r.isSuccess()) {
(Database.Error e : r.getErrors()) {
(e Database.DuplicateError) { }
}
}
}