You need to sign in to do that
Don't have an account?

When Milestone SLA "Expired" update Case field Status on the "Expired" ? How to start trigger?I want to update case for the Status =="Expired" when milestone Expired time.
public with sharing class UpdateCaseExpiredMilestoneStatus { private static final String RT_CASE_ALCADA = RecordTypeUtil.getByDevName('Case', 'Al_ada'); public static void execute(){ Set<Id> sIdsCase = new Set<Id> (); List<Case> lstCase = new List<Case> (); for (Case iCase : (List<Case>) Trigger.new) { if (iCase.RecordTypeId == RT_CASE_ALCADA && (TriggerHelper.changedField(iCase, 'Status') && iCase.MilestoneStatus == 'Open Violation' && iCase.Status == 'Novo')) { sIdsCase.add(iCase.Id); lstCase.add(iCase); System.debug('Caiu no if'); } } System.debug('lstCase' + lstCase); if(lstCase.isEmpty()){return;} caseExpiredMilestoneStatus(lstCase); } public static void caseExpiredMilestoneStatus(List<Case> lstCase){ List<Case> lstCasesStatus = new List<Case>(); for(Case iCase : lstCase){ iCase.Status = 'Expirado'; lstCasesStatus.add(iCase); } if(!lstCasesStatus.isEmpty()){ Database.update(lstCasesStatus); } } }