Sub topic 5
Matching existing records and avoiding duplicates
This chapter assumes you can prepare a CSV file and have run a basic import with the Data Import Wizard. You should also know what Account, Contact, and Lead records are. Here you will learn how the wizard decides whether a CSV row is a new record or an existing one, and how to stop it from creating duplicates.
Why matching matters
If you import a row that already exists in Salesforce and the wizard has no way to recognize it, it creates a second copy. Duplicates split activity history, inflate reports, and confuse users. Matching is how the wizard recognizes a row as a record you already have.
You choose the import action on the first wizard page:
| Action | What it does |
|---|---|
| Add new records | Always creates records. Does no matching. |
| Update existing records | Changes matched records. Unmatched rows are skipped. |
| Add new and update existing records | Updates matched rows and creates the rest. |
Only the second and third actions use matching. "Add new records" is the one that produces duplicates, so use it only for data you know is new.
What you can match on
The wizard offers a fixed set of match fields for each object.
| Object | Match by |
|---|---|
| Account | Name, or Name and Site, or Salesforce ID, or a custom external ID field |
| Contact | Name, Email, or Salesforce ID, or a custom external ID field |
| Lead | Name, Email, or Salesforce ID, or a custom external ID field |
An external ID is a custom field you mark as "External ID" when you create it. It usually holds a key from another system, such as a customer number. It is the most reliable match field because it is unique and does not change when someone edits a name.
Matching on Name is the weakest option. Two different people can share a name, and a typo in either place breaks the match. Prefer Email for contacts and leads, and an external ID when you have one.
Email,FirstName,LastName,Phone
[email protected],Ana,Silva,555-0100
[email protected],Ben,Okoye,555-0101
[email protected],Ana,Silva,555-0199In this file the first and third rows have the same email. The wizard does not merge rows within one file, so remove or combine such rows before you upload.
How the decision works
The diagram shows what happens to each row when you choose "Add new and update existing records" and match contacts by Email.
Two edge cases matter. A blank match value means nothing can match, so the row is treated as new. If several existing records share the match value, the wizard cannot pick one, so the row is not safely imported. Search your data for these cases before a large run.
Matching related records
The wizard also matches rows to records they should point to. When you import contacts, you can set "Match Account by" so each contact links to an existing account by Name, Site, or ID. When you import leads into campaigns or accounts into a hierarchy, the same idea applies. If the wizard cannot find the related record, the row's link stays empty or the row fails, depending on the field. Check the result email for these rows.
Other protections
- Duplicate rules. If your org has active duplicate rules, they can still apply during an import. A rule with a Block action causes matching rows to fail. Ask your admin which rules are active.
- Export first. Export the existing records with their IDs and look for the match values in your CSV. A simple spreadsheet lookup finds overlaps before you import.
- Use a sandbox. Run the import with a small sample first and confirm that updates hit the intended records.
Exercise
You are importing 2,000 contacts that came from a marketing list. Many may already exist in Salesforce. Which import action and match field would you choose, and what two checks would you do on the CSV file beforehand?
Show answer
Choose "Add new and update existing records" and match by Email, or by an external ID if the contacts have one. Do not use "Add new records", because it does no matching. Before importing, remove or merge rows with duplicate emails inside the file, and check for blank emails, since blank rows cannot match and will always create new records. Also export current contacts to find existing matches and to have a backup.