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
sieb4mesieb4me 

apex code change - need to execute on new case or field change

Hi,
I have a following code on entitlement process and want to exeute if only if case is new or case field priority is changed, how do i modify it?

Thanks


CODE:

global class myMilestoneTimeCalculator implements Support.MilestoneTriggerTimeCalculator {   
     global Integer calculateMilestoneTriggerTime(String caseId, String milestoneTypeId){
        Case c = [SELECT Priority, Priority_On_Complete__c  FROM Case WHERE Id=:caseId limit 1];
              
        if (c.Priority_On_Complete__c == null)  {
          if (c.Priority != null && c.Priority.equals('P1'))
              return 3;
          else 
               if (c.Priority != null && c.Priority.equals('P2')) 
            return 6;
       else 
        if (c.Priority != null && c.Priority.equals('P3')) 
            return 9;
         else return 0;
        }
        else  {
            if (c.Priority_On_Complete__c.equals('P1'))
              return 3;
         else 
        if (c.Priority_On_Complete__c.equals('P2')) 
            return 6;
        else 
        if (c.Priority_On_Complete__c.equals('P3')) 
            return 9;
        else return 0;
            
        }
                        
     }
}
Brian FordBrian Ford