Skip to main content
added 100 characters in body
Source Link
Santanu Boral
  • 36.2k
  • 8
  • 45
  • 72

Design

Flow

Flow

Resolution tracker

Outcome

outcome

Flow

Resolution tracker

Design

Flow

Resolution tracker

Outcome

outcome

Source Link
Santanu Boral
  • 36.2k
  • 8
  • 45
  • 72

This is tricky requirement but exactly I have achieved.

  1. Create Entitlement Process and define Miletones based on which Case will enter into the milestone. Milestone type will be Independent. You will define single Milestone for this process like Resolution Time.

  2. If you have a different SLA based on case types then you need to write code for proper SLA assignment. Let's say Support1 Team's SLA is 24hrs and Support2 team's SLA is 18 hours. So in that scenario, SLA should be dynamic. Use this apex class in Milestone configuration.

code

global class CaseMilestoneTimeCalculator implements Support.MilestoneTriggerTimeCalculator 
{   
    public CaseMilestoneTimeCalculator(){  
    }       
      
    global Integer calculateMilestoneTriggerTime(String caseId, String milest)      
    {
        //need to query the SLA defined in Custom setting/Meta data type for respective user or group
    }
}
  1. Create a separate object say Resolution Tracker which will take the data from Milestone object. This tracker will have all the milestone data related to Case. Take all the fields from Milestone object to create this object and lookup to CaseId. And insert or update record based on case status changes.

  2. Since you have to complete one milestone when case status changes so, before starting a new milestone, update previous milestone with completed date.

code

public class MilestoneUtils 
{
    public static void completeMilestone(List<Id> caseIds, DateTime complDate) 
    {

        List<CaseMilestone> cmsToUpdate = [select Id, completionDate
                                            from CaseMilestone cm
                                            where caseId in :caseIds and IsCompleted =False
                                            and completionDate = null limit 1];
            if (cmsToUpdate.isEmpty() == false)
            {
                for (CaseMilestone cm : cmsToUpdate)
                {
                    cm.completionDate = complDate;
                }
            update cmsToUpdate;
            }
    }
}

Flow

Resolution tracker