You need to sign in to do that
Don't have an account?
Jayaramu T 9
please find the below code i am getting error at line 14 "CMileS" is a for loop local variable. please suggest me how to rectify this? highlited as bold
List<CaseMilestone> lp_setmstones = new List<CaseMilestone>(); Set<Id> mstoneIDs = new Set<Id> (); LIST<CaseMilestone> setmstones; for (CaseMilestoneSetting__c CMileS : CMileSs){ mstoneIDs.add(CMileS.MilestoneID__c); } // Find all CaseMilestones matching our criteria in our caselist if(system.test.isRunningTest()) { setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID IN :mstoneIDs AND CompletionDate=NULL'); } else { setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+ CMileS.CaseCriteria__c+ 'AND CaseID IN:caselist AND MilestoneTypeID IN :mstoneIDs AND CompletionDate=NULL'); } // Update the CompletionDate for each CaseMilesone for (CaseMilestone updatemstone : setmstones){ updatemstone.CompletionDate= Datetime.now(); } // Execute the update for all the Milestones in this set lp_setmstones.addAll(setmstones);
Steven Nsubuga
CMileS.CaseCriteria__c should be removed from the query because it is not even being checked against anything in the SOQL query.
sfdc fresher
CMileS is just local variable for that loop only,so we cant use it outside.in order to rectify it write thoese if and else conditions inside the for loop