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?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
You can query the
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')
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