Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 36 ยท Data Management

Duplicate Management and Data Quality in Salesforce

Keep Salesforce data clean: matching rules, duplicate rules, alert and block actions, merging records, required fields and validation, and a data quality scorecard with JavaScript stand-ins.

Bad data quietly ruins a CRM. Two records for the same customer mean two salespeople calling them, split history and wrong reports. Missing phone numbers mean campaigns that cannot reach anyone. Inconsistent states ("CA", "Calif.", "California") break territory rules and reports. Data quality is therefore a standing administrator job, not a one-time clean-up. This lesson covers Salesforce's duplicate management tools and the habits that keep data trustworthy.

As elsewhere, the Salesforce menus are described in words, and the examples are labelled JavaScript stand-ins that imitate the logic; they are not Salesforce and show no real output.

Two parts: matching rules and duplicate rules

Duplicate management has two cooperating pieces.

Matching rules decide what counts as a possible duplicate. They compare fields of a new or edited record with existing records. Salesforce supplies standard matching rules for accounts, contacts, leads and person accounts, and you can create custom ones (Setup, then Matching Rules). A rule lists field comparisons with a matching method:

  • Exact: the values must be identical (ignoring case).
  • Fuzzy: values may differ slightly. Fuzzy methods include First Name (handles nicknames like Bob and Robert), Last Name, Company Name (ignores "Inc." or "Ltd" and common abbreviations), Phone, Street, City, Zip, Email and Title, and Acronym and Keyboard Distance for typos.

A matching rule combines fields with AND/OR logic; for example: (First Name fuzzy AND Last Name exact AND Email exact) OR (Phone exact AND Last Name exact). You can also tick Blank fields match if empty values should count as equal (usually leave it off, or you will flag everything with no email as duplicates).

Duplicate rules decide what to do when a match is found. A duplicate rule names the object, the matching rule it uses, and an action for two moments:

When Choices
On create and on edit Allow (with an optional alert and a report entry) or Block (the user cannot save)
Alert text A message shown to the user, such as "A contact with this email already exists."
Actions Alert, Report (log the duplicate in a Duplicate Record Set you can report on), or Block

You can also add conditions (for example, apply this rule only when the owner is in a certain role) and choose whether the rule checks across related objects (for example, matching leads against contacts).

Rules can run in an API context too. If an integration or the Data Loader loads data, a Block rule rejects the row with DUPLICATES_DETECTED. If you want to allow the load and review duplicates later, use Allow plus Report, or enable "Allow users to save duplicates through API" settings carefully.

flowchart TD
  N["User saves a record"] --> M["Matching rule compares to existing records"]
  M -->|"No match"| S["Saved"]
  M -->|"Match found"| D{"Duplicate rule action"}
  D -->|"Allow + alert"| A["User sees warning, can save anyway"]
  D -->|"Block"| B["Save refused with message"]
  D -->|"Report"| R["Saved; logged in a Duplicate Record Set"]

Matching rules find candidates; duplicate rules decide what happens.

Finding existing duplicates

New rules protect future data, but your org already holds duplicates. Options:

  • Report on Duplicate Record Sets and Duplicate Record Items (the report types created when the Report action ran).
  • Use a Duplicate Jobs feature (available in higher editions) that runs a duplicate rule over existing data on demand.
  • Export, deduplicate in a spreadsheet or script, and re-import with the Data Loader (always back up first).
  • Use a data-quality app from the AppExchange for fuzzy deduplication at scale.

Merging

Salesforce can merge up to three records of the same type (accounts, contacts, leads, cases in some setups). You choose a master record and, field by field, which values survive. The children of the losing records (contacts, opportunities, activities, notes) move to the master. The losing records go to the Recycle Bin, but the merge cannot be undone as a merge, so merge carefully: check the Id of the master record, because integrations and external systems may reference it.

Know the rules: you cannot merge records of different types, users must have the right access and an owner may be reassigned; some record types (for example person accounts) have restrictions.

Preventing bad data

Tools beyond duplicate rules:

  • Required fields and validation rules, for example AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Next_Step__c)) with an error message.
  • Picklists instead of free text, and dependent picklists (Country, then State).
  • Global value sets and State and Country picklists (standardized addresses) so that "California" and "CA" are normalized.
  • Formula fields and flows that standardize values (for example UPPER(BillingCountry)).
  • Lookup filters that limit which records can be chosen in a lookup.
  • Page layouts and record types that ask only for what makes sense.
  • Email, URL and phone field types that validate format.
  • Ownership and inactive-user rules: reassign records of departed users promptly.

Monitoring quality

Define a small scorecard and put it on a dashboard: completeness (percent of contacts with email and phone), validity (percent with a valid format), uniqueness (duplicate rate), timeliness (percent of accounts touched in the last 12 months), and consistency (values within allowed sets). Review it monthly, assign owners, and fix at the source (the form or the integration), not only in the data.

Stand-in: fuzzy matching

This stand-in is not Salesforce's matching engine. It compares names after normalizing them, which is the idea behind exact versus fuzzy company-name matching.

JS Stand-in: exact versus normalized matching

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Stand-in: a data quality scorecard

JS Stand-in: completeness, validity and uniqueness

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the job of a matching rule?

    Matching rules compare fields; duplicate rules act on the result.
  2. 2. A duplicate rule is set to Allow with Report. What happens when a match is found?

    Allow lets the save proceed; Report logs the duplicate for later review.
  3. 3. How many records can be merged at once?

    Salesforce merges up to three records of the same type at a time.
  4. 4. Which approach prevents 'CA', 'Calif.' and 'California' all appearing?

    Picklists enforce one set of values at the point of entry.

Summary

  • Matching rules find possible duplicates (exact or fuzzy); duplicate rules decide to alert, block or report.
  • Merge up to three records, choosing a master record and the surviving field values.
  • Prevent bad data with required fields, validation rules, picklists and lookup filters.
  • Measure quality (completeness, validity, uniqueness) and fix problems at the source.

Next: Backup, export and recovery