Salesforce Error 'INVALID_CROSS_REFERENCE_KEY' occurs while updating Quote records whose parent Contacts have been deleted

1.2k views Asked by At
  1. Even if the parent Contact records have been deleted from the org, the quote field 'ContactId' is still populated with the ID of deleted contact record. This is resulting into reported exception while updating such Quote records.
  2. ContactID field is populated on impacted Quote records, though the same field on the record detail page appears blank on UI.
  3. Updating any field on such records is giving the 'invalid cross reference key' error due to the presence of 'ContactId' which does not exist.

Clearing out the 'ContactID' field via DEV console (either through query editor, or code snippet) does not give any error upon save. And then the reported error stops occurring when any other fields are updated after that. Please help to understand why the 'ContactID' field would not become blank upon deletion of Contact records for some of these Quote records.

1

There are 1 answers

0
eyescream On

Real lookup field should auto clear, do you have any proof, screenshots? Does it happen even for people with View All Data?

I suspect you either copied value to a text field and it doesn't get wiped

or there's some sharing issue at play (maybe non-admin user can't see the contact, maybe they can see but not edit)