The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Detecting wrong-parent Contacts after a migration using External IDs and SOQL (opens in a new tab)

You will learn how to test whether Contacts still point to the correct Account after a migration, using External ID keys, a child-to-parent SOQL export, and a source-to-target comparison.

Why read this

The method works with native tools and needs no third-party code.

  1. Confirm keys are unique
  2. Export Contacts with parent key
  3. Match Contacts on their key
  4. Compare Account keys
The wrong-parent check compares Account keys for each Contact across two orgs

Record Ids usually change between orgs, so comparing AccountId values across a migration tells you nothing. The article proposes a stable External ID on both Account and Contact, then checks that the parent Account’s key is the same on each side for every Contact.

The workflow starts with uniqueness and blank-count queries on the keys, then uses a single child-to-parent SOQL export from Contact via Data Loader to pull Account.External_Key__c onto each row. The same view can be built as a Contacts & Accounts report. Rows are then matched on the Contact key and the Account keys compared, with blanks flagged as unresolved and missing rows reported separately.

The author notes limits: the method needs a shared stable key, Data Loader does not support nested subqueries, and a clean parent check does not validate field values, sharing or record types. The article is written by the vendor of a paid CSV comparison tool, which it discloses.

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

Worth reading?