Why FirstName, LastName, Company field not found in FieldPermission query result

field-level-securityfieldsleadspermission-setspermissions

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 :

enter image description here

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 for Lead, 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

Schema.DescribeFieldResult dfr = Schema.SObjectType.Lead.fields.FirstName;
System.debug(dfr.isPermissionable()); //returns false

Indicates whether FieldPermissions can be specified for the field (true) or not (false).

enter image description here

Related Topic