//ICRE
Map<String,String> objName = new Map<String,String>();
for(Schema.SObjectType f : Schema.getGlobalDescribe().Values()){
if(f.getDescribe().isCustom()){
objName.put(f.getDescribe().getLabel(),f.getDescribe().getName());
}
}
if(objName.containsKey('ICRE')){
Map<Id,sObject> mapClonedICRE = new Map<Id,sObject>();
string sObj = objName.get('ICRE');
system.debug('sObj::'+sObj);
sObject oInstance;
sDynamicQuery = this.dynamicQuery(sObj);
query = 'SELECT ' + sDynamicQuery + ' FROM '+ sObj +' WHERE Product__c IN :lstProdOfSourceEE limit 5000';
lstofICRE = Database.query(query);
system.debug('lstofICRE::'+lstofICRE);
for(sObject oICRE :lstofICRE){
oInstance = Schema.getGlobalDescribe().get(sObj).newSObject();
oInstance = oICRE.clone(false, false, false, false);
system.debug('oInstanceNew::'+oInstance);
//oInstance.oInstance.get('ownerId') = userinfo.getuserid();
/*oInstance.ownerId = userinfo.getuserid();
if(mapClonedPrdwithSourcePrdId.containskey(oICRE.Product__c)){
oInstance.Product__c = mapClonedPrdwithSourcePrdId.get(oICRE.Product__c).Id;
}else{
oInstance.Product__c = null;
}
if(oICRE.Start_Date__c != null)
oInstance.Start_Date__c = String.valueOf(oTargetEE.get('Start_Date__c'));
if(oICRE.End_Date__c != null)
oInstance.End_Date__c = oTargetEE.End_Date__c;
if(oInstance.Product__c != null){
mapClonedICRE.put(oICRE.Id, oInstance);
}*/
}
if(!mapClonedICRE.isEmpty()){
Insert mapClonedICRE.values();
system.debug('ICRE::'+mapClonedICRE.values().size());
system.debug('ICRECon::'+mapClonedICRE.values());
}
}
Error on this Line -
oInstance.Product__c = mapClonedPrdwithSourcePrdId.get(oICRE.Product__c).Id;