function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdc_1sfdc_1 

How to call permission set inside apex class which declared over custom metadata

I have two permission set (API Name: RDM014 and RDM015) which need to declare inside custom metadata.

1)Can I defined directly this permission set inside record of custom metadata which have fields name BU logic as below: 
BU Logic Fields:RecordType.DeveloperName,Obr_Has_Onboarding__c,RDM014,RDM015(Go through attached image of custom metadata)


2)Now this permission set declared over custom metadata, I need to call this inside apex class have method 'evaluateFields' using else if condition in below logic.

Please help me out how to call this permission set of custom metadata inside below apex method using else if

List<String> buLogicFields=String.isBlank(businessUnitDataList[0].BU_Logic_Fields__c) ? new List<String>() :  businessUnitDataList[0].BU_Logic_Fields__c.split(',');
   
   private String evaluateFields(List<String> buLogicFields, sObject sObj){
        String recordValueString='';
        for(String objFld:buLogicFields){
            String fieldVal='';
            if(objFld.contains('RecordType.')){
                fieldVal=getRecordTypeName(objFld,(Id)sObj.get('RecordTypeId'));
            }else{
                fieldVal=String.valueOf(sObj.get(objFld));
            }
            recordValueString+=(recordValueString=='')?fieldVal:(','+fieldVal);
        }
        return recordValueString;
    }
    
    private String getRecordTypeName(String fieldName, Id recordTypeId){
        list<RecordType> rt = [SELECT Id,Name, DeveloperName FROM RecordType WHERE SobjectType= :objectName and id =:recordTypeId];
        if((fieldName=='RecordType.DeveloperName')&&(rt.size() == 1)){
            return rt[0].DeveloperName;
        }else if((fieldName=='RecordType.Name')&&(rt.size() == 1)){
            return rt[0].Name;
        }
        return null;
    }custom data