function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mmaxtrammaxtra 

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 ...

BritishBoyinDCBritishBoyinDC
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...
MMA_FORCEMMA_FORCE

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?

Thanks

MMA

BritishBoyinDCBritishBoyinDC

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

luckymeluckyme
Are you inserting a row in a Share object?
kshannonkshannon

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.

 

Thanks,

Kyle

Scott.MScott.M
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?
nickwick76nickwick76

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?

Thanks!

 

BR / Niklas

Suraj Tripathi 47Suraj Tripathi 47
Hi,
Greetings!

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!

Regards,
Suraj Tripathi