SOQL Statement to Query Field Level Security on particular Profiles

Here is how you can get the Field Level Security for particular profile:

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit 
FROM FieldPermissions 
WHERE parentId IN ( SELECT id 
                    FROM permissionset 
                    WHERE PermissionSet.Profile.Name = 'System Administrator') 

Depending upon the objects in your org, the above query would return number of records i.e. each record represents a field on each object. So for 20 objects with each of them having 20-50 custom fields it would return 20*50 number of records.

You can restrict the number of records by looking at a specific sObject. Ex:

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit 
FROM fieldPermissions 
WHERE SObjectType = 'Opportunity' 
AND parentId in ( SELECT id 
                  FROM permissionSet 
                  WHERE PermissionSet.Profile.Name = 'System Administrator') 

Hope this helps.

Tags:

Soql