• PChalicheemala
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
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();

}