Invalid Cross Reference Id Error

Getting the “Invalid Cross Reference Id” Salesforce error and unsure what it means? If so, that error means that the Salesforce Id used in a lookup or master-detail relationship field is not valid.


1) Wrong Object Type – The relationship field is being set to the Salesforce Id of the wrong object. For example, if field A is a lookup to the Account object, an opportunity Id can’t be used in this field.

2) Record Deleted – The record no longer exists. This can happen if someone deleted the record while a user or the system is inserting or updating records. It can also happen during a request when the record is initially inserted but then rolled back so the code still has a reference to the record with an id in memory but the record does not exist in the database.

3) Relationship Field Pointing To Wrong Object – This happens less frequently but is still a cause of this error. Sometimes, there are multiple objects in the system with the same name and a user chose the wrong object to have the lookup or master-detail point to. This happens because Salesforce will show the same object name without any further detail in the object list when defining the field so it’s not immediately clear which to choose.

To choose the correct object when there are multiple with the same name, inspect the drop down list in the browser and view the values for the select list items. Identify the correct one to use and then choose it from the drop down list.

If this information has helped or if you have other causes, please comment below.

Happy Coding,


4 thoughts on “Invalid Cross Reference Id Error”

  1. Thanks Luke.

    As I just discovered, this error can also happen if a Partial Copy sandbox doesn’t transfer a record that is in a lookup field. I hadn’t run into this problem until this week.

    The lookup field with the non-existent Contact was empty when viewing the record, so I didn’t notice a problem at first. But when editing it showed up as a lookup to “Unknown Contact”, thereby preventing the Save.

    1. Cathy,

      Ah! That’s a good one to know. I can’t believe Salesforce even allows that! Thanks for the Info.

  2. Hey All,
    I just got this error when trying to insert a valid Account in the Account Name field from the standard contact object. Why would this happen??

Comments are closed.