Wednesday 9 May 2018

How to fetch object permission for all profiles in SOQL query

You may be in a situation to verify object permission details for all or specific profile. So you may check object details from UI one by one by navigating each profile, and this will be time-consuming. Instead, you can fetch details by querying ObjectPermission. Here is the example,


Query specific object permission for all Profiles:

  1. SELECT Profile.Name FROM PermissionSet WHERE IsOwnedByProfile = TRUE AND Id IN (SELECT ParentId FROM ObjectPermissions WHERE PermissionsRead = TRUE AND SObjectType = 'CustomObject__c') ORDER BY Profile.Name

You can check all object level permission in the query. Such as,
PermissionsRead 
PermissionsCreate
PermissionsEdit
PermissionsDelete
PermissionsViewAllRecords
PermissionsModifyAllRecords


The below approach also works but the profile name will be displayed as [Object Object] in Query Editor,

  1. SELECT Parent.Profile.Name FROM ObjectPermissions WHERE Parent.IsOwnedByProfile = TRUE AND SObjectType = 'CustomObject__c'

Reference:

Stackexchange

Object Permission

6 comments:

  1. Hello Bro
    if you are looking for php tutorial then you may click here

    ReplyDelete
  2. Awesome Post Keep it Up , Best Tutorials for Online Learners php tutorials

    ReplyDelete
  3. I need to get case object record type profile access. Can you share the query ?

    ReplyDelete
  4. QUICK EASY EMERGENCY URGENT LOANS LOAN OFFER EVERYONE APPLY NOW +918929509036 financialserviceoffer876@gmail.com Dr. James Eric

    ReplyDelete

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...