+ Start a Discussion
PChalicheemalaPChalicheemala 

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

Hi, I'm trying to update user record with custom field. But I'm getting an exception: Update failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, You cannot update a customizable setup entity, except when running tests
 
The user trying to update the user record has system admin privileges and 'API Enabled' selected. This code is called from custom link (s-control). Tried the following cases and failed in both cases. Please advice?
 
Try 1:

User sObj = new User(Id=UserInfo.getUserId());

sObj.Next_Level_Approver__c = toApproverId;

//update user with new approver

try {

update sObj;

} catch(Exception e) {

e.getMessage();

}

Try 2:
 

User sObj = [Select Id, Next_Level_Approver__c  where Id=:UserInfo.getUserId()];

sObj.Next_Level_Approver__c = toApproverId;

//update user with new approver

try {

update sObj;

} catch(Exception e) {

e.getMessage();

}

Ron HessRon Hess
you cannot update the user object from Apex code.
gbalakrigbalakri
Ron
Is this still the case. I would like to update a custom field on the user object from a triggert that is occuring in another object
Girish
jpwagnerjpwagner
Use API version 12.0