Map<ID,String> currencyMap = new Map<ID,String>();
Set<ID> parIdSet = new Set<ID>(); for(Channel_Sales_Forecast__c obj : salesforecastNewUpdate) { //oldforecast Channel_Sales_Forecast__c oldforecast = (Channel_Sales_Forecast__c)Trigger.oldMap.get(obj.Id); if(obj.CurrencyIsoCode != oldforecast.CurrencyIsoCode) { parIdSet.add(obj.id); currencyMap.put(obj.id, obj.CurrencyIsoCode); } }
System.debug('asdfasdfsdfasdfsadf');
List<Channel_Sales_Forecast_Details__c> csfDetail = new List<Channel_Sales_Forecast_Details__c>(); //查询预测详情页上已有的记录 csfDetail = [select id,CurrencyIsoCode,Channel_Sales_Forecast__c,Channel_Sales_Forecast__r.CurrencyIsoCode from Channel_Sales_Forecast_Details__c where Channel_Sales_Forecast__c in :parIdSet]; //???// for(Channel_Sales_Forecast_Details__c obj : csfDetail) { // //Channel_Sales_Forecast__c forecast = (Channel_Sales_Forecast__c)Trigger.oldMap.get(obj.Id); //if(obj.CurrencyIsoCode != salesforecastNewUpdate[0].CurrencyIsoCode) { //如果header页货币种类发生了改变,那么相应的详情页列表中所有的记录都要改变 obj.CurrencyIsoCode = currencyMap.get(obj.Channel_Sales_Forecast__c); //} }
System.debug('csfDetail is = ' + csfDetail);
update csfDetail; } } }