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?

Checking Contact parent accounts after a Salesforce data migration (opens in a new tab)

You will learn why matching field values is not enough to verify a migration, and how to test each Contact's parent Account through a stable external key, using either pandas or Google Sheets formulas.

  1. Source Contact to its source Account ID
  2. Source Account ID to its stable key
  3. Target Contact to its target Account ID
  4. Compare the two Account keys
The check follows each Contact's parent Account through the stable key to the target org

A Contact can keep its name and email after a migration and still be attached to the wrong Account. Comparing field values will not catch this, and record IDs usually change between orgs, so they cannot be compared directly either. The article proposes a stable key, such as an External ID field, that identifies the same Account in both exports. The check follows the Contact’s source Account to its key, then confirms that the target Contact’s Account has the same key.

The article works through a small set of invented example CSVs. A pandas script merges the Contacts, maps each parent through the keys, and flags a WRONG_PARENT result for one Contact whose target Account points to the wrong record. The same logic is then rebuilt as Google Sheets formulas using INDEX and MATCH, with uniqueness checks on the keys and an EXACT comparison because MATCH is case-insensitive.

The author notes practical cautions for real exports. Lookups that return errors should be investigated rather than hidden with IFERROR, and the ranges must be widened for larger files. The check only verifies the relationships in the files loaded, so it does not certify a whole migration.

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

Worth reading?