You need to sign in to do that
Don't have an account?
Amit Singh 1
Open Mile Stone When a case turns to Open from Closed Stage
Can some one provide me the code to open the milestone. I have triged the code and getting the error that you can not change the completion date of milestone that already exited the entitlement process.
Thanks!
AMit SIngh
public static void reopenMilestone(List<Id> caseIds, String milestoneName, DateTime complDate, Map<Id, String> case_Map) { System.debug('#### complDate = '+complDate); List<Case> caseList = new List<Case>(); List<Entitlement> ent = [Select Id From Entitlement LIMIT 1]; List<CaseMilestone> cmsToUpdate = [select Id, startDate, completionDate,MileStoneTypeId, caseId from CaseMilestone cm where caseId in :caseIds and cm.MilestoneType.Name=:milestoneName limit 1]; if (cmsToUpdate.isEmpty() == false){ for (CaseMilestone cm : cmsToUpdate){ cm.completionDate = null; cm.startDate = System.now(); } System.debug('#### cmsToUpdate = '+cmsToUpdate); System.debug('#### caseList = '+caseList); runOnce = true; update cmsToUpdate; }Please help me.
Thanks!
AMit SIngh
As error states, you cannot change the milestone completion date for cases that are exited from entitlement process.
Please check your Entitlement process exit criteria from setup -> Entitlement Management -> Entitlement Processes. Normally case should exit entitlement process when case is closed.
Kindly mark it is as an answer if this resolves your query.