The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Recommended

Finding Contacts with a blank AccountId after a Salesforce migration (opens in a new tab)

You will know how to find Contacts with no Account using SOQL or a report, why such Contacts are private by default, and how to triage them before attaching any of them to an Account.

  1. Query Contacts where AccountId is null
  2. Compare count with source system
  3. Label each row attach, private or investigate
  4. Attach only reviewed Attach rows
  5. Re-run null query and spot-check
Triage steps for orphan Contacts after a load

After a migration, a Contact can keep all its field values and still have a blank AccountId. That is an orphan, which differs from a wrong-parent Contact whose AccountId points at the wrong company. The article notes that Salesforce Help says Contacts not linked to an Account are private, visible only to the owner and to administrators with View All Data or Modify All Data, and not governed by Contact Sharing Rules. It lists example causes such as Accounts loaded after Contacts or a failed parent lookup on insert, while stressing that a blank AccountId is one finding to be assessed rather than a diagnosis.

The query is a SOQL statement filtering on AccountId = null, optionally combined with an External ID field to narrow to migration-loaded records, and a count can be compared with the source system’s count of Contacts without an account. The same set can be produced from a Data Loader export or a standard report. The author recommends a triage step that labels each row as attach, leave private or investigate, never attaching the whole list automatically, matching on Contact Id, and re-running the null query after updates.

The piece closes with its limits: intentional private Contacts are normal, a null check cannot detect a wrong parent, and users without View All Data may under-count what they can see. It also promotes a paid CSV comparison tool for wrong-parent checks.

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

Worth reading?

Checking a Contact export for orphans, duplicate External IDs and picklist mismatches after a load (opens in a new tab)

You will learn how to count orphaned Contacts, unresolved AccountIds, duplicate External IDs and picklist values outside the allowed API names, using spreadsheet formulas, a standard-library Python script and SOQL.

Why read this

The article also explains what these checks cannot catch.

  1. Export Contacts and Accounts
  2. Flag blank and unresolved AccountIds
  3. Find duplicate External IDs
  4. Compare picklist to allowed API names
Four checks run on the exported files after a load

A successful Data Loader insert or upsert can still leave a Contact export with problems the success file does not show. The article covers blank AccountIds, AccountIds that point to no Account in the export, External IDs shared by more than one Contact, and picklist values that are not among the field’s allowed API names.

The walkthrough works through example files and three methods: spreadsheet formulas that flag each problem column, a Python script using only the standard library, and SOQL queries to confirm the counts against the live org. It notes that SOQL returns picklist API names rather than labels, and that values loaded into an unrestricted picklist can be stored without being listed in Setup.

The author stresses that orphans are a review list rather than a delete list, and that a wrong but existing AccountId needs a separate source-to-target comparison. The example data is fabricated and the reader must adapt field headers to their own org.

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

Worth reading?