FieldPermission is the Salesforce internal standard object. It is used to store field permissions given through Permission set and profiles.
For example if you want to find access of custom fields like Rate__c and Compititor__c from Account object. You can use below query to find the field usage:
SELECT SobjectType,Field, PermissionsRead,PermissionsEdit, Parent.Name, ParentId FROM FieldPermissions WHERE PermissionsRead = True and Field in ('Account.Rate__c','Account.From1__c','Account.Compititor__c') AND SobjectType = 'Account'For Read access you can use 'PermissionsRead' and for Edit access, you can use PermissionsEdit field of FieldPermissions object.
ParentId contains either permission set id. If you looking for field access in permission set then you can use Parent Id as it is But if you are looking for profile id then please follow:
- When you assign FLS through profile, Salesforce stores ParentId in the form of Permission set.
- So to get actual profile ids, you have to add Parent.Name field in the query.
- That will give you 'X00e600...' id. Remove X00 from the id and rest of it is profile id.