I want to find out, if another user has READ permission on a specific object (I don't care about record access/sharing). Is there a way to accomplish this via APEX?

I do NOT want to find out if the running user has access to the object, since that is rather straight forward.

My use case is: I want to assign ownership of custom object records to users based on their properties. Unfortunately a user can only own a record if he has at least read access to the object. If I try to assign the owner regardless, I'll get an exception.

Also this must be applicable in a non-test context, so. runAs() won't do.

My question is: How can I check read (or CRUD in general) access to objects for other users?

Any help is appreciated.


1 Answer 1


You can try like below

String desireUserId = UserInfo.getUserId(); // or pass any other user id.
User u = [select profileId from user where id =: desireUserId];
String profileId = u.profileId;

List<ObjectPermissions> 0bjPermissionList = [SELECT Id, SObjectType, 
PermissionsRead FROM ObjectPermissions WHERE parentid in (select id from 
permissionset where PermissionSet.Profile.Id=: profileId)];

Before assigning, chedk if that user has PermissoinsRead field is true.

  • While this does help to a majority extent, is there a way to not check this on a profile level? I mean I have read only users and editor users both sharing the same profile.
    – M M
    Sep 25, 2023 at 6:57

You must log in to answer this question.

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