trigger DailyReportSetHospitalCount on Daily_Report__c (after update) { /* List accParentList = new List(); List actDateList1 = new List(); List accParentParentList = new List(); List actDateList2 = new List(); */ List eIdList = new List(); List drId = new List(); for (Daily_Report__c dr : Trigger.new) { if (Trigger.isUpdate) { if (Trigger.oldMap.get(dr.Id).get('Status__c') != dr.Status__c) { drId.add(dr.Id); } } } List ecList = [Select Id, ActivityDate__c, AccountParentId__c, AccountParentParentId__c from Event__c where AccountParentId__c <> null and Daily_Report__c in :drId]; for (Event__c ec : ecList) { // 報告日は現在日時の前後100日以内のみ対応 Integer days = ec.ActivityDate__c.daysBetween(Date.today()); if (days >= -ControllerUtil.ReportDayRange && days <= ControllerUtil.ReportDayRange) { /* accParentList.add(ec.AccountParentId__c); actDateList1.add(ec.ActivityDate__c); if (!String.isBlank(ec.AccountParentParentId__c)) { accParentParentList.add(ec.AccountParentParentId__c); actDateList2.add(ec.ActivityDate__c); } */ eIdList.add(ec.Id); } } // 活動1,2,3を空更新 List ahdrList = [select Id from Activity_History_Daily_Report__c where EventC_ID__c in :eIdList]; List eoList = [select Id from Event_Oppotunity__c where EventC_ID__c in :eIdList]; List esList = [select Id from Event_Service__c where EventC_ID__c in :eIdList]; if (ahdrList.size() > 0) update ahdrList; if (eoList.size() > 0) update eoList; if (esList.size() > 0) update esList; //ControllerUtil.updateAccountMonth(accParentList, actDateList1, accParentParentList, actDateList2); }