0

I have a custom field custom_field__c in Opportunity object and using APEX or metadata API (workbench) is there a way to find what are the set field level security profile is set for that given custom field?

for an example, I need to know what profile is checked Visible/Read-Only.

below image is for ref.

enter image description here

2

You can query field permissions by using SOQL on the FieldPermissions object.

For example:

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit FROM FieldPermissions

This would return a lot of rows: every field returned multiplied by the number of permission sets. So if you have 200 fields and 20 permission sets, you'll return 4000 rows. You can help reduce this by filtering based on object and specific profile. For example:

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit
FROM FieldPermissions
WHERE SObjectType = 'Opportunity'
AND ParentId IN (
  SELECT Id 
  FROM PermissionSet 
  WHERE PermissionSet.Profile.Name = 'System Administrator'
)

Or you could look at a specific field instead:

SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit
FROM FieldPermissions
WHERE SObjectType = 'Opportunity'
AND Field = 'Opportunity.Custom_Field__c'

Edit

As Adrian said in the comments, the multiplier is against Permission Sets, not Profiles so I've updated the answer to reflect that fact. Furthermore:

PermissionsRead

If true, users assigned to the parent PermissionSet can view this field. A FieldPermissions record must have at minimum PermissionsRead set to true, or it will be deleted.

This is your "visible" column. In other words, should the User be able to see the field?

PermissionsEdit

If true, users assigned to the parent PermissionSet can edit this field. Requires PermissionsRead for the same field to be true.

This is your "read-only" column. Should the User be able to edit the field? Or, can they only read it.

| improve this answer | |
  • Thanks for the reply and what is Read-Only & Visible represent? in the FieldPermissions object? – Nick Kahn Sep 15 '17 at 16:52
  • I have updated my question so the new image shows exactly what I'm looking to achieve, I just need to know What System Administrator and Standard User have access to Visible & Read-Only – Nick Kahn Sep 15 '17 at 17:04
  • Multiplied by the number of permission sets, not profiles. – Adrian Larson Sep 15 '17 at 17:04
  • Adrian what do you mean by Multiplied by the number of permission sets? can you elaborate little bit more – Nick Kahn Sep 15 '17 at 17:15
  • @AdrianLarson Thanks for that! I've updated the answer to reflect that. – Dan Jones Sep 18 '17 at 7:55

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.