+ Start a Discussion

INVALID_CROSS_REFERENCE_KEY????Pleaseeee help me understand this

My test coverage is 100% but average is 86% with 1 failure...

I dont understand this error:

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: id value not valid for the users profile: {0}: [RecordTypeId]


I do not understand ...

I am pretty sure that the issue is that the user you are running the test under is setting a record type they don't have access to in their profile - assuming the user is you, check that you have access to the record type you are using...

Thank you for the help... I did check the Profile setting which is System Admin. And I made all recordtypes available for me, making the recordtype I am using the default.

Should I just make it Master in the settings of the profile for that object recordtype?




I don't think that should matter - so long as it is available, the test should be able to reference it 

Are you inserting a row in a Share object?

MMA_FORCE, I am currently trying to solve that problem now, only I do not see where you made it accessible for system user on recordtypes... If you could help me out I'd greatly appreciate it.




I'm getting the same error in the DataLoader. I'm using an Id for a record type that I know I have access to and that I know exists. Has anyone been able to resolve this?

I am trying to upsert Cases. One of many columns is 'OwnerId' and one is 'RecordTypeId'. All of them fail with the error message:


Case Record Type: id value not valid for the users profile: 012T00000000VfykAE


The user has a profile which has this specified recordtype available in his profile (record type settings).


I have upserted several other objects with no problem. The only difference that I can think of is that the Case object don't have an owner the same way as for example the Opportunity. For a case you specifiy OwnerId, but for an Opportunity you can point out an external field on the owner record (User).


Any idea?



BR / Niklas

Suraj Tripathi 47Suraj Tripathi 47

This error is occurred due to wrong id is using inside the record type and may be login user has not access to that record type.

If you find your Solution then mark this as the best answer. 

Thank you!

Suraj Tripathi