0

Is there a way to read or set Field Level Security on ScorecardMetric object fields in Apex?

I can create a custom field on ScorecardMetric but can't use Apex to set FLS for this field.

1

Currently it is not possible to read or set Field Level Security on ScorecardMetric object fields. Also it is not possible to get DescribeFieldResult for such fields or DescribeSObjectResult for Scorecard related objects including Scorecard, ScorecardAssociation and ScorecardMetric.

0

This is the way where you can check the field access.

String objName = 'Account';                 //Standard Object

//Custom field Value is case sensitive (to lowercase)   
String fieldname = 'customerpriority__c';   

Map<String, Schema.SObjectField> objectFields = new Map<String, Schema.SObjectField>();
//Map to get all fields
objectFields = Schema.getGlobalDescribe().get(objName).getDescribe().fields.getMap();  

if(objectFields.keySet().contains(fieldName) && objectFields.get(fieldName).getDescribe().isAccessible()){                                          
    system.debug('Field is Accessible: '+fieldName);
} else {
    system.debug('Field is not Accessible: '+fieldName);
}

I hope it will help you.

1
  • This does not work for ScorecardMetric. – Rahul Gawale Jan 3 '20 at 11:51

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.