Sub topic 14
SLA-Driven Escalation with Entitlements and Milestones
This chapter assumes you can create queues, assignment rules, and escalation rules, and that you know how business hours work. You should also be comfortable reading SOQL. The Apex example is optional.
Why escalation rules sometimes fall short
An escalation rule looks at a case's age. It compares the time since creation or last modification with a threshold, then reassigns or notifies. That fits a flat promise such as "any case untouched for four hours goes to a manager."
Many support contracts are more specific:
- Premium customers get a first response in one hour. Standard customers get eight.
- The resolution target is a separate clock that starts after the first response.
- The clock stops while you wait for the customer.
- Agents should get a warning before the target is missed, not only after.
Entitlement Management models these promises. A service-level agreement (SLA) is the response or resolution time you have promised a customer. Entitlements and milestones track that promise per case and run actions when it is at risk or broken.
The building blocks
| Concept | What it is | Where it lives |
|---|---|---|
| Entitlement | A record stating what support a customer is owed | Linked to an Account, and optionally a Contact, Asset, or Service Contract |
| Entitlement process | A timeline of milestones that applies to cases | Setup, with a case type and entry criteria |
| Milestone | A required step with a time limit, such as "First Response" | A milestone type, used inside a process |
| Case milestone | One running instance of a milestone on one case | The `CaseMilestone` object |
| Milestone actions | Success, warning, and violation actions | Each milestone in a process |
The entitlement connects the customer to a process. The process connects to the case, and the case then gets one CaseMilestone record for each milestone that applies.
Setting it up
- In Setup, enable Entitlement Management. Then add the Entitlement field to the case page layout, and add the Entitlements related list to accounts.
- Create milestone types, such as First Response and Resolution. A milestone type is only a name and an optional description. The timing lives in the process.
- Create an entitlement process of type Case. Choose when the clock starts, when it stops, and which business hours apply.
- Add milestones to the process. For each one, set entry criteria (for example
Priority = High) and a time limit in minutes. - Define the actions for each milestone, as described in the next section.
- Activate the process and create entitlements on accounts that reference it.
- Link entitlements to cases. You can do this by hand, or by turning on the setting that assigns the default entitlement from the contact or account.
Then add the Milestone Tracker component to the Lightning case record page. Agents use it to see the countdown and to complete milestones.
Milestone actions
Each milestone offers three groups of actions, and each group can contain several time-based steps.
- Success actions run when the milestone is completed before its target.
- Warning actions run at a set time before the target. For example, you can run them when 75 percent of the time is used.
- Violation actions run when the target passes without completion.
Each step can send an email alert, create a task, update a field, or start a flow. A typical violation setup updates IsEscalated to true, then reassigns the case to a manager queue, then emails the support lead.
Two details are easy to miss. First, the milestone itself can recur: a milestone can repeat independently or recursively, which suits "update the customer every 24 hours until resolved." Second, the actions use field updates, not the escalation action UI. Reassigning a case to a queue is a field update on Owner, so the queue must exist and be selectable.
Business hours, pausing, and timing
A milestone's target is calculated in business hours when the process or case is tied to a business hours record. A two-hour first response opened at 4:30 PM on Friday is due on Monday morning if the hours end at 5:00 PM. The holiday list you built in the business hours chapter applies here as well.
The clock can also stop. When a case enters a status that you flag as stopping the SLA clock, such as "Waiting on Customer," the case's IsStopped field becomes true. The target is pushed back when the case resumes. This is what separates SLA tracking from an age-based escalation rule. An age rule keeps counting while you wait for the customer.
Querying and completing milestones
The CaseMilestone object lets you report on SLA health. This query lists running milestones that have not yet been violated, soonest target first:
SELECT Id, Case.CaseNumber, MilestoneType.Name, TargetDate, IsViolated
FROM CaseMilestone
WHERE IsCompleted = false AND IsViolated = false
ORDER BY TargetDate ASCChanging IsViolated = false to true gives you the cases that already missed an SLA. This is a good source for a report.
Milestones normally complete in two ways. An agent clicks Complete in the Milestone Tracker, or the process completes the milestone automatically when its criteria are met, for example when Status changes to In Progress. You can also complete one from Apex by setting CompletionDate:
public with sharing class MilestoneService {
public static void completeMilestone(Id caseId, String milestoneName) {
List<CaseMilestone> open = [
SELECT Id, CompletionDate
FROM CaseMilestone
WHERE CaseId = :caseId
AND MilestoneType.Name = :milestoneName
AND IsCompleted = false
];
for (CaseMilestone cm : open) {
cm.CompletionDate = System.now();
}
update open;
}
}Call it from a trigger or flow when a first outbound email is sent, for instance, so that the First Response milestone completes without agent action.
Choosing between the three tools
| Requirement | Best fit |
|---|---|
| Send any case untouched for N hours to a queue | Escalation rule |
| Different targets per customer tier | Entitlements and milestones |
| Warn agents before a deadline | Milestone warning actions |
| Pause the clock while waiting for the customer | Entitlements and milestones |
| Route work to available agents by skill or capacity | Omni-Channel |
Escalation rules are simpler to build and to explain. Entitlements take more setup and need accounts to carry entitlement records, but they are the only one of these tools that models per-customer promises.
Common errors
- No milestones appear on a case. The case has no entitlement, or the case does not meet the process's entry criteria. Check the Entitlement field first.
- Milestones start at the wrong time. The process start condition may be Case Creation Date when you wanted a later status change. Review the process setting.
- A new process version has no effect on open cases. Cases already in progress keep the version they started on. Test with new cases.
- A warning action never fires. The warning time must fall before the violation time, and a milestone with a very short limit may complete before the warning is reached.
- Violation actions reassign to the wrong owner. Another rule or automation, such as an assignment rule on update, may overwrite the owner afterward.
- Entitlement is blank on web and email cases. Cases created through channels do not always get an entitlement. Use the default entitlement setting, or set
EntitlementIdin a flow.
Exercise
A support team promises Gold customers a one-hour first response and a four-hour resolution, and the clock must stop while a case waits on the customer. Would you use an escalation rule or an entitlement process? Name the pieces you would create.
Show answer
Use an entitlement process, because the targets differ per customer tier and the clock must pause. Create two milestone types (First Response and Resolution) and an entitlement process with a one-hour and a four-hour milestone for Gold cases. Add warning and violation actions to each milestone. Flag the "Waiting on Customer" status as stopping the clock. Create a Gold entitlement on each Gold account, linked to the process, and make sure cases receive that entitlement.
Exercise
A case shows no Milestone Tracker countdown, though its account has an active Gold entitlement. List two causes to check.
Show answer
First, the case's Entitlement field may be empty. The account having an entitlement does not link it to the case automatically unless the default entitlement setting is on. Second, the case may not match the entry criteria of the milestones in the process, for example because its Priority is not the value the milestone requires.