function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
utz1utz1 

fire a trigger after field is updated from entitlement

Hello, 

I am working on entitlement process. When milestone is violated I am updating checkbox field on case object. I want after chechk box is checked. This trigger should fire. This trigger reset milestone on case. Well, trigger is working. 

My concern is, when Checkbox on case object checked by violation action it does not autoamtically fires trigger and reste the milestone. Insetad to run trigger I have to edit case. I want this should be done automatically

Thanks,
Utz

trigger startdate on Case (after update) {
    
   List<CaseMilestone> cmUpdatedList =new List<CaseMilestone>();
   List<Case> cList = [SELECT CaseNumber, AccountId, Id, ContactId, Reset_Milestone__c, Subject, Description, ContactEmail, contact.name,  Product__c, SuppliedEmail 
   FROM Case WHERE Reset_Milestone__c = true AND Id IN :Trigger.new];  
   List<CaseMilestone> cmList= [SELECT Id , CaseId, StartDate, IsViolated, case.Reset_Milestone__c, IsCompleted FROM CaseMilestone where CaseId =: cList AND IsCompleted = false];
   for(case cd : cList)
   {
       if(cd.Reset_Milestone__c == true )
       {
           for(CaseMilestone cms : cmList)
           {
                   cms.StartDate =  System.now();
                   system.debug('********cms.StartDate*********'+cms.StartDate);
                   cmUpdatedList.add(cms);
           } 
       }
       Update cmUpdatedList;
      

     
}