I have an object that is having multiple child objects. I want to perform certain actions only if the current record has child records associated with it. For this I am checking the related list's size first, dynamically.But I am facing issues while saving my code :
for(Lead objLeadRec : lstLead) {
for(LC_Setup_Map_Related_List__c objRelatedList1 : lstRelatedListRecords){
relatedChildObjName = objRelatedList1.tdc_tlc__Child_Object__c.replace('__c','s__r');
System.debug('relatedChildObjName'+relatedChildObjName);
if(objLeadRec.relatedChildObjName.size() >0){
hasRelatedListRecords = true;
}
}
}
I am facing issue on this line, since the list name which I want to query, I have created using a string ,
if(objLeadRec.relatedChildObjName.size() >0){
Can anyone suggest any workaround. Can't hardcode object names as this code belongs to a managed package and the object names can be different in different orgs.