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.
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
.
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.