When deploying records with Gearset's data loader, some users encounter an error that reads:

INVALID_CROSS_REFERENCE_KEY: Record Type ID: this ID value isn't valid for the user: :RecordTypeId -- 

This article explains why this error occurs, and how to resolve it.

The cause

When the data loader sets the record type ID field, it needs to set a record type that is valid for the profile of the user doing the deployment. Even for a user with Modify all data turned on, it's possible to restrict the set of valid record types, although this behaviour is not usually the default.

The record type ID field is used to set the record type of the records being deployed. The data loader fills in this value by looking at the record type names on both the source and target and using the record type with the same name on both sides. If there's no such record type, the tool will leave the field blank. This will force Salesforce to use the default record type for the deployment user.

Fix 1: don't deploy record types

One fix for the error is to not deploy the record type field. The record type ID will be left blank, and Salesforce will set it as the default for the deployment user. If the record type does not need to be set correctly, this approach should make the deployment succeed.

Fix 2: make sure the target user has the appropriate record types assigned 

If it's important that the records have the correct record type ID set, then you'll need to ensure the user on the target Salesforce organization has all of the appropriate record types assigned to them.

To do this:

  • Log into the target organization and navigate to Setup > Manage Users (for Salesforce Classic - Users for Salesforce Lightning Experience) > Profiles. 
  • Open the profile for the user that will be used to perform the deployment.
  • Under the Custom Record Type Settings section, open the settings for any record type needed for the deployment. For each record type, adjust the Selected Record Types so that it contains the --Master-- record type (or, alternatively, all of the available record types).

Selecting the --Master-- record type ensures that Gearset can write any record type ID to new records and makes it easier to perform similar data deployments in future if new record types are added. 

Still having issues?

Contact our team and we'll be happy to help. See how.

Did this answer your question?