Why does adding person account records not respect specified record types?


Question:

I'm facing an issue while trying to insert person account records into my org with the Person Accounts feature enabled. I'm using the Record Type feature in SFDMU and specifying the RecordTypeId in the export.json and source CSV file.

However, when I run the SFDMU command, I receive a warning that says "[WARN] {Account} 500 missing parent lookup records were found. See MissingParentRecordsReport.csv for details." Consequently, accounts are created with the default record type, not as person accounts.

What could be causing this discrepancy?


Answer:

To load account records with their specified record types, it's essential to provide accurate source CSV files and correctly configure the export.json. Ensure that the column names in your CSV files align with those expected by SFDMU. Here’s how to structure your export.json and CSV files:

Example export.json:

{
    "objects": [
        {
            "query": "SELECT Id FROM RecordType WHERE IsActive = true",
            "operation": "Readonly",
            "externalId": "DeveloperName;NamespacePrefix;SobjectType"
        },
        {
            "query": "SELECT Id, Name, Phone, RecordTypeId FROM Account LIMIT 1",
            "operation": "Upsert",
            "externalId": "Name"
        }
    ],
    "excludeIdsFromCSVFiles": true
}

You can omit the explicit declaration of the RecordType object in the export.json if it's automatically included due to its reference from the Account object.

Account.csv:

IsPersonAccount,Name,Phone,RecordType.$$DeveloperName$NamespacePrefix$SobjectType
false,ACC_10277,+972,TestAccountRT;Account

RecordType.csv:

$$DeveloperName$NamespacePrefix$SobjectType
TestAccountRT;Account

This setup ensures that each account record is correctly associated with its specified record type during the import process.

Last updated on 20th Apr 2024