13

Since I couldn't think of how to write this query off the top of my head, I thought it might be worth sharing. How can I query which Profiles have Read permission on a specific object? I knew it would have something to do with ObjectPermissions and PermissionSet, but had to look up the documentation for both to piece it together.

1 Answer 1

17

The first query I got to work was on the ObjectPermissions object:

SELECT Parent.Profile.Name FROM ObjectPermissions
WHERE Parent.IsOwnedByProfile = true AND SObjectType = 'MyObject__c'

This query gets exactly the data I wish, but in the Query Editor, gives the dreaded:

[object Object]

Left Inner Join to the rescue! More palatable:

SELECT Profile.Name FROM PermissionSet
WHERE IsOwnedByProfile = true AND Id IN (
    SELECT ParentId FROM ObjectPermissions
    WHERE PermissionsRead = true
    AND SObjectType = 'MyObject__c'
)
1

You must log in to answer this question.

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