[SalesForce] How to track SLA/OLA for different processes in Salesforce

I need the assistance on the below requirement.

Assume we've the 10 processes in a Single End-End process flow and let's say I want to keep the track of the process from step-2 to step-6 for the SLA / OLA. Assume at step-2 my request submitted and it goes through the no. approval process like Success and Reject, so I want to track this in time SLA, how much time it has taken to success. How we can do that ?

Assume it has same record or two different records (Salesforce system might have integration with other system). Can we track this information using the Entitlement Processes and Milestones ?

Can we calculate SLA between two processes ?
Please guide what can be done ?

Note: Yes, it's related to Case object (it may be on other object but not sure though) and have different statuses etc., based on process steps and want to track how much time taken for each step.

What can be done if the case is violated ? Assume in 1st milestone is violated, then when the 2nd milestone could be initiated ?

Best Answer

This is tricky requirement but exactly I have achieved.

Design

  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

Outcome

outcome

Related Topic