How can I find a list of users having View All Data or View All opportunities permission?

1.1k views Asked by At

I am trying to run below query in Salesforce Developer Console to find out how many permissionSetIDs exist with View All Data Permissions or View All Opportunities. What's wrong with the below query?

SELECT Id, Name, PermissionsViewAllData, IsOwnedByProfile 
FROM PermissionSet
WHERE Id IN (SELECT ParentId 
             FROM ObjectPerms 
             WHERE SobjectType='Opportunity' 
               AND PermissionsViewAllRecords=true)

I see below error:

WHERE Id INn (SELECT ParentId FROM ObjectPerms WHEREe SobjectType='Opportunity'

ERROR at Row:1:Column:112 sObject type 'ObjectPerms' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

1

There are 1 answers

0
Pavel Slepiankou On

You just need to change object name to correct type from ObjectPerms to ObjectPermissions

SELECT Id, Name, PermissionsViewAllData, IsOwnedByProfile
FROM PermissionSet
WHERE Id IN (SELECT ParentId
             FROM ObjectPermissions
             WHERE SobjectType='Opportunity'
               AND PermissionsViewAllRecords=true)