# What actions can be triggered automatically when a case milestone warning or violation occurs?

**Topic:** Service Cloud · **Difficulty:** Medium · **Tags:** Service Cloud, Milestone Actions, SLA Automation

Read it on the site: https://www.forcechallenges.com/interview-questions/what-actions-can-be-triggered-automatically-when-a-case-milestone-warning-or-violation-occurs

## Answer

**Basics:** In Service Cloud, Entitlement Management attaches an Entitlement Process to a Case. The process has Milestones (for example First Response in 1 hour, Resolution in 8 hours). Milestone actions are the automations that run on those timers: warn the owner, escalate to the manager, flag the case, or record that the SLA was met.

**How it works:**
1. Setup > Entitlement Settings: enable entitlements and milestones; create Entitlements for Accounts.
2. Create Milestones, then an Entitlement Process with ordered milestones, their time triggers and business hours.
3. For each milestone add actions: Success, Warning (time trigger before target) or Violation (at or after target), and choose email alert, task, field update or outbound message.
4. A case gets an entitlement and process, creating CaseMilestone records with TargetDate. Completing the milestone (criteria met or manual/Flow/Apex) fires Success; otherwise the time trigger fires Warning or Violation.

**Advanced / deep dive:** Milestone actions use the time-trigger framework similar to old workflow actions, so they run asynchronously close to, but not exactly at, the target time. Milestones complete automatically when their completion criteria are met, or programmatically by setting CaseMilestone.CompletionDate. Each time-trigger can have multiple actions, and you can stagger warnings (for example 30 and 10 minutes before). Business hours and pauses (for example Status = On Hold using the entitlement process's "Pause" conditions) alter the real target time. Workflow Rules are retired for new development in favor of Flow, but milestone actions still rely on these legacy action types; newer releases add Flow-based options (verify availability). A common architecture is to set a field update on violation and let a record-triggered Flow handle the complex escalation.

**Code / config example:**
```apex
// Complete open First Response milestones for cases that just got a public comment
List<CaseMilestone> toClose = [
    SELECT Id FROM CaseMilestone
    WHERE CaseId IN :caseIds AND MilestoneType.Name = 'First Response'
      AND IsCompleted = false];
for (CaseMilestone cm : toClose) cm.CompletionDate = System.now();
update toClose;
```

**Hidden gotchas & must-remember points:**
- Time triggers run asynchronously, so timing is approximate.
- Warning actions fire only if the milestone is still open at that time.
- Business hours on the entitlement process change when violation happens.
- Milestones that are completed late still count as violated.
- Case must have an entitlement process or no milestones exist.
- Do not rely on Process Builder or Workflow Rules for new work; use Flow where supported.

**Best practice:** Keep milestone actions minimal (field update or flag) and delegate escalation logic to a record-triggered Flow.

---
Source: ForceChallenges · last updated 2026-11-02
