How can I get in my service class(Apex class) that a logged in user is having view all and modify all permissions on any particular object.


You can query the permissionsetassignment object to determine if a user has PermissionsViewAllData or PermissionsModifyAllData (I believe, check the documentation). See https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_permissionsetassignment.htm for more information.

Edit: You can also query for specific objects. The items mentioned above are the global permissions.

| improve this answer | |
  • Can we query ObjectPermissions object instead? – rahul gawale May 28 at 14:28
  • 1
    @rahulgawale if you want the permissions for a specific object, yes. – sfdcfox May 28 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.