1 risposta
Hi Satish , You will need to do the following to use the metadata/ custom setting for mapping in the apex code.
Map<String , String> mapOfFieldMapping = new Map<String , String>();
for(Mapping__c mapObj : [Select CaseMapping__c, WorkOrderMapping__c from Mapping__c]){
mapOfFieldMapping.put(mapObj.WorkOrderMapping__c , mapObj.CaseMapping__c);
}
for(Case caseRec : newItems){
WorkOrder workOrderObj = new WorkOrder();
for(String workOrderField : mapOfFieldMapping.keyset()){ //iterate the Workorder field Name
workOrderObj.put(workOrderField , caseRec.get(mapOfFieldMapping.get(workOrderField))); // get fieldname of case ,then it's record value using get method
}
woLIst.add(workOrderObj);
}
if(woLIst.size() > 0){
insert woLIst;
}
Hope this helps.