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.

2 Answers 2

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.

1

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. Commented Jan 3, 2020 at 11:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .