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 

how do i bulkify following code

global class myclass implements Support.MilestoneTriggerTimeCalculator {   
     global Integer calculateMilestoneTriggerTime(String caseId, String milestoneTypeId){
        Case c = [SELECT Priority, Priority_On_Complete__c  FROM Case WHERE Id=:caseId];
        MilestoneType mt = [SELECT Name FROM MilestoneType WHERE Id=:milestoneTypeId];
        
        if (c.Priority_On_Complete__c == null)  {
        
        
        if (c.Priority != null && c.Priority.equals('P1'))
        return 60;
        
        else 
    
    if (c.Priority != null && c.Priority.equals('P2')) 
        
            return 240;
     
    else 
    if (c.Priority != null && c.Priority.equals('P3')) 
        return 480;
    
    else return 0;
        }
        else  {
          if (c.Priority_On_Complete__c.equals('P1'))
        return 60;
        
        else 
    
    if (c.Priority_On_Complete__c.equals('P2')) 
        
            return 240;
     
    else 
    if (c.Priority_On_Complete__c.equals('P3')) 
        return 480;
    
    else return 0;
          
          
        }
        
                        
     }
}
sieb4mesieb4me
Currently it runs this query for many cases and gives 101 error since its being called for case updates as it resides on entitlment milestone, we want to ensure it doesnt throw the error and is only called for the case that is being updated.
PratikPratik (Salesforce Developers) 
Hi,

I don't see any issue in your code which will hit SOQL limit, can you check is there any other trigger that is geting invoked because of any condition met as a result of this trigger.

Thanks,
Pratik