Friday, November 10, 2017

Get report on object permission

We don't have any standard way to get a report on profile permission on the different object in a single go. In Salesforce, all access is given via a permission set so if you query on permission set assignment you can see who is assigned to what permission set.

In Salesforce, we have an object called ObjectPermission which has a direct relation with Permissionset

If you query on object permission you will set all the object permission in a single go.

Below query will provide you the matrix to get the object permissions based on profile 

SELECT Parent.Profile.Name, SobjectType, PermissionsCreate, PermissionsRead, PermissionsEdit, 
                       PermissionsDelete, PermissionsViewAllRecords, PermissionsModifyAllRecords 

                       FROM ObjectPermissions where Parent.Profile.Name <> NULL


You might have looked at the query filter and observed that I am using Parent.Profile.Name <> NULL I have used it because it will escape all the permission not provided by the profile like given by Permission set to the user. 


The code can be found here or the unmanaged package from here. It will look like below. I have given two tabular formats to view the data you can use as per your need.





The same can be done with FieldPermissions object to get the report on the FLS. You can also use the AssigneId of PermissionAssignment to identify all the access of an user.





1 comment:

Tips on passing Salesforce AI Associate Certification

  🌟 Motivation to Pursue the Salesforce AI Associate Certification 🌟 The world of technology is in a state of perpetual evolution, and on...