I need to be able to check the FLS (Field-Level Security) settings for a specific user. Since the user in question will not be executing the check I cannot use the DescribeFieldResult class for the check.

Is this possible in Apex or using the Salesforce API?


You can query the FieldPermissions object using the User's Profile as the ParentId field.

SELECT Id, Field, PermissionsRead, PermissionsEdit FROM FieldPermissions 
WHERE ParentId IN 
  (SELECT Id FROM PermissionSet WHERE ProfileId IN 
    (SELECT Id FROM Profile WHERE DeveloperName = 'StandardUser')) 
AND SobjectType = 'Account'

Unfortunately this by itself won't take into account other PermissionSet's, so you may need to aggregate all the PermissionSets in addition to the Profile (which shouldn't be too difficult).

  • You cannot nest sub-selects. WHERE Profile.DeveloperName = 'StandardUser' should work in this case. Also, as a note, profiles have underlying PermissionSet records available in Apex/API which are distinguished from other permission sets by the field IsOwnedByProfile. source – geeljire May 30 '16 at 11:44
  • This does not return any cases where PermissionsRead = false – Charles Koppelman Oct 2 '20 at 17:49

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.