I'm trying to get all fields and its read and write permission using below query
SELECT Field, PermissionsRead, PermissionsEdit FROM FieldPermissions WHERE SObjectType ='Lead' AND parentId IN ( SELECT permissionSetId FROM PermissionSetAssignment where assigneeId IN('#assignee_Id #'))
I'm getting expected result :
But still some fields are missing in the output like "FirstName, LastName, Company, Street, City, Country…"
assignee_Id is System Administrator and having Field-Level access to all fields.
Facing same issue with Account and Contact.
Best Answer
FieldPermissions represents the enabled field permissions for the parent Permission Set. It's not a representation of everything that someone has access to.
The fields you identified:
FirstName
,LastName
,Street
, etc are fields that Salesforce sets access to.You'll notice, within a permission set, that when you set
Object Settings
forLead
, those fields aren't included (meaning they're not permissionable).You can see this another way through the
fields
property of DescribeSObjectResults (or through workbench explorer). A field has a property called permissionable