0

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.

2

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

1
2

Fields that are database required (e.g. Name), and fields that are "compound fields" (e.g. City) are not included in the field level security fields. The former are always required and therefore don't need to be checked for access, while the latter are turned on/off at the compound field level (e.g. Address contains City).

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.