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
nbknbk 

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY on User object

Hello All,

 

I am getting an issue while updating user object from Partner User profile.  Tried with without sharing in the class level and other ways to overcome the issue but could't find the fix.

 

I have raised a case to salesforce and they confirmed that you can not update User object from Partner user profile and it is allowing only from System Admin profile.

 

Please let me know if you have workaround for this issue.

 

Sample Code:

@future  
    public static void disableUser(Set<ID> userIds)
        {     
       
  List<User> lstusers = [Select id from User where id in: userIds];
           
            for(User u : lstusers)
                {
                   u.isActive = false;
                
   }
            update lstusers;//throwing error

 

From Debug log:

04:31:04.056 (56044017)|EXCEPTION_THROWN|[708]|System.DmlException: Update failed. First exception on row 0 with id 005F0000002F981IAC; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []
04:31:04.056 (56953655)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id 005F0000002F981IAC; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id

Best Answer chosen by Admin (Salesforce Developers) 
nbknbk

Please ignore my previous conversations on the partner user unable to update the user object.

 

The partner is able to update the User object and the issue has been solved by adding try catch blocks in the method

 

Sample Code:

@future  
    public static void disableUser(Set<ID> userIds)
        {     
       try{


  List<User> lstusers = [Select id from User where id in: userIds];
           
            for(User u : lstusers)
                {
                   u.isActive = false;
                
   }
            update lstusers;//throwing error

}

catch (Exception ex)

{throw ex;}

 

}

All Answers

Vinita_SFDCVinita_SFDC

Hello Krishna,

 

It seems the partner profile doesn't have read/write access on User object, please confirm.

nbknbk

Yes..Vinita..

Currently the partner profile doesn't have read/write access on User object. I observed that the issue coming after winter 14. I have seen the Sharing model allows for User object but could't see the object from OWD.

https://success.salesforce.com/ideaView?id=08730000000BrjVAAS

 

Vinita_SFDCVinita_SFDC

Are you not able to edit access in profile?

nbknbk

Please ignore my previous conversations on the partner user unable to update the user object.

 

The partner is able to update the User object and the issue has been solved by adding try catch blocks in the method

 

Sample Code:

@future  
    public static void disableUser(Set<ID> userIds)
        {     
       try{


  List<User> lstusers = [Select id from User where id in: userIds];
           
            for(User u : lstusers)
                {
                   u.isActive = false;
                
   }
            update lstusers;//throwing error

}

catch (Exception ex)

{throw ex;}

 

}

This was selected as the best answer