Can I use SOQL to list all Profiles with a specific type of access to a standard field? i.e. 'List all profile with Read-only access to the "Account Name" field on the Contact object'

What would that syntax be?

  • Checking only Profiles would not be appropriate since CRUD/FLS can be set through Permission Sets too.
    – Phil W
    May 20 '21 at 21:18

You can query the FieldPermissions object.

Example, to find all Profiles with Read-Only access to the "Account Name" field on Contact:

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit, ParentId, Parent.IsOwnedByProfile
FROM FieldPermissions 
WHERE SObjectType = 'Contact'
    AND Field = 'Contact.AccountId'
    AND Parent.IsOwnedByProfile = TRUE
    AND PermissionsEdit = FALSE

FieldPermissions are handled by PermissionSets or Profiles and using Parent.IsOwnedByProfile can help narrow that down. Similarly, if you want to see what field permissions a profile grants, see this answer:

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit 
FROM FieldPermissions 
WHERE parentId IN ( SELECT id 
                    FROM permissionset 
                    WHERE PermissionSet.Profile.Name = 'System Administrator') 
  • Thanks, but how do I add the 'Profile NAME' to this query? That's the part I'm struggling with. Thanks!
    – Bob Mount
    May 24 '21 at 18:16
  • Try adding Parent.Profile.Name to the SELECT. Technically the Parent is a PermissionSet, and if it's related to a Profile, then you need to make one more hop.
    – nbrown
    May 24 '21 at 21:46

Found the answer. This query lists all Profiles that have Edit access to the Contact.AccountId (Account Name) field:

SELECT Parent.Profile.Name, Parent.Label, Parent.IsOwnedByProfile, SobjectType, Field, PermissionsEdit, PermissionsRead 
FROM FieldPermissions
WHERE SobjectType = 'Contact' AND Field = 'Contact.AccountId' AND PermissionsEdit = true
  • I get [object Object] in the Parent.Profile field instead of Name
    – Shane K
    Jul 19 '21 at 12:38

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.