While I am updating the list of user record's isActive flag to false, I am getting an error.

Update failed. First exception on row 1 with id <User_is>; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: <user_id>: [] Class..: line <>, column <>"

List<User> userList = [SELECT Id, isActive FROM User WHERE AccountId = :userAccId];
for(User u : userList){
    u.IsActive = false;
update userList;
  • 1
    Welcome to SFSE. Please take a moment to read How to Ask and take the tour. Please edit your post to clarify what kind of user is triggering the action. Is it a community user who triggers the Apex? Aug 1, 2022 at 13:55

1 Answer 1


INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY means that the user who is trying to make the update does not have access to a related element that is required for the record to be updated and saved in SFDC.

So basically make sure that: 1-You don't update a record that does not exist, 2-You don't update object field that is build-in/read-only, 3-You perform the action using the user who does not have the right access to modify the object

You can check the object access for the profile:-

Go to setup 🡪 profile 🡪 object setting and select the object that you are trying to update 🡪 edit 🡪 enable edit or modify all option.

enter image description here

Or you can check that user having what type of access on that record by using DML:- List lstUserRecordAccess = [SELECT RecordId,MaxAccessLevel,HasAllAccess, HasEditAccess, HasReadAccess, HasTransferAccess FROM UserRecordAccess WHERE UserId = 'Enter user id ' AND RecordId = ' Enter record id'];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .