The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Recommended

Finding hidden duplicate accounts after a Salesforce Data migration (opens in a new tab)

You will learn how to normalise legacy keys, count duplicates in a spreadsheet and in SOQL, separate true duplicates from key collisions, and repoint child records before deleting a duplicate Account.

  1. Normalise the legacy key
  2. Count raw and normalised keys
  3. Classify each duplicate group
  4. Repoint child records
  5. Delete the duplicate
The duplicate clean-up sequence for migrated Accounts

Matching record counts after a migration can hide duplicates. Re-run loads, insert calls used where an upsert on an External ID was needed, and keys that differ only by case, spaces or leading zeros all leave duplicates behind. Salesforce duplicate and matching rules do not examine a legacy key unless a rule is built for it.

The article walks through normalising the key with spreadsheet formulas, counting raw and normalised keys, and classifying each group as unique, exact duplicate, hidden duplicate or key collision. A SOQL GROUP BY query with HAVING clause provides the same check inside the org, though it catches case differences only, not leading zeros or trailing spaces.

Before deleting anything, the author chooses a survivor, usually the Account with the most Contacts, and repoints Contacts, Opportunities and Cases to it with Data Loader or the Account merge operation. The checklist ends with marking the External ID field Unique so the next load cannot insert the same key twice.

Read the original at dev.to (opens in a new tab)

Worth reading?