Skip to content

PranavNagrecha/AwesomeSalesforceSkills / skills/admin/escalation-rules

escalation-rules

Verified

Configure and troubleshoot Salesforce Case Escalation Rules: time-based escalation entries, business hours configuration, escalation actions (email alerts and reassignment), and diagnosing why cases are not escalating. Covers the EscalationRules metadata shape, businessHoursSource and escalationStartTime semantics, staged escalationAction thresholds, deploy-inactive parallel-run cutover, and monitoring escalated cases. Trigger keywords: escalation rule, case not escalating, SLA breach notification, escalate after X hours, reassign case automatically, IsEscalated. NOT for SLA milestone timers — use admin/entitlements-and-milestones. NOT for case routing on creation — use admin/assignment-rules. NOT for the calendar itself — use admin/business-hours-and-holidays.

references/examples.md

View on GitHub
# Examples — Escalation Rules

## Example 1: SLA Breach Notification for a Software Support Org

**Context:** A B2B software company has a 4-hour SLA for P1 cases. The support operations team needs to ensure that the support manager is notified when a P1 case is not updated within 4 hours, and that the case is reassigned to the escalations queue if it remains open at 8 hours.

**Problem:** Without escalation rules, cases slip past SLA thresholds silently. Support managers only discover breaches during weekly reviews, at which point the customer relationship is already damaged.

**Solution:**

1. Navigate to Setup > Service > Escalation Rules > New.
2. Name the rule "Case SLA Escalation" and check Active.
3. Add Rule Entry 1:
   - Criteria: `Priority equals P1`
   - Escalate Case When: Over 4 hours old
   - Business Hours: Use org default (24/7, since P1 is always-on)
   - Age Over Based On: Case Created Date
4. Add Escalation Action for Entry 1 at 4 hours:
   - Notify: Case Owner's Manager
   - Reassign To: (leave blank — notification only)
5. Add Escalation Action for Entry 1 at 8 hours:
   - Notify: Escalations Queue
   - Reassign To: Escalations Queue
6. Save and verify one P1 test case.

**Verify it fired.** Setup shows configuration, not behaviour. After the first working day, run this against yesterday's P1 cases and check that the ones older than the threshold moved:

```sql
SELECT CaseNumber, Priority, Status, OwnerId, IsEscalated,
       CreatedDate, LastModifiedDate
FROM Case
WHERE Priority = 'P1' AND CreatedDate = LAST_N_DAYS:1
ORDER BY CreatedDate
```

A P1 row older than 8 hours whose `OwnerId` is still the original agent means the second stage did not run. Read `references/gotchas.md` in order: engine batching first, then criteria mismatch, then the calendar.

**Why it works:** Entry criteria `Priority = P1` ensures lower-priority cases are unaffected. Two time-layered actions on the same entry provide progressive escalation: warn first, reassign second. The 8-hour reassignment action guarantees a human takes ownership even if the original agent is unavailable.

---

## Example 2: Business-Hours-Aware Escalation for a Regional Service Team

**Context:** A US-based service team works Monday–Friday, 8 AM–6 PM Pacific. Standard cases must be resolved within 8 business hours. Without business hours configuration, cases created on Friday at 5 PM would trigger escalation early Saturday morning — when no one is available to act.

**Problem:** Escalation notifications landing outside business hours generate noise, erode trust in the system, and result in cases being escalated then never followed up on until Monday — making the escalation meaningless.

**Solution:**

1. Setup > Business Hours > New:
   - Name: "US Pacific Business Hours"
   - Check Active
   - Time Zone: Pacific Standard Time
   - Hours: Monday through Friday, 8:00 AM to 6:00 PM
   - Uncheck Saturday and Sunday
2. Setup > Escalation Rules > Edit active rule > Add Rule Entry:
   - Criteria: `Type equals Standard`
   - Escalate Case When: Over 8 hours old
   - Business Hours: Check "Use Business Hours" → select "US Pacific Business Hours"
   - Age Over Based On: Case Created Date
3. Add Escalation Action: notify case owner at the 8-hour mark.
4. Assign the Business Hours record to cases (the `BusinessHoursId` field or "Business Hours" field on Case).

**Predict the fire time before you wait for it.** Anonymous Apex converts the business-hours arithmetic into a datetime you can put in the test plan, instead of watching the inbox:

```apex
// Predicted escalation moment for one case, given the entry's threshold in minutes.
Integer minutesToEscalation = 480;              // 8 business hours
Case c = [SELECT Id, CaseNumber, CreatedDate, BusinessHoursId FROM Case WHERE CaseNumber = '00001234'];
Id bhId = c.BusinessHoursId != null
    ? c.BusinessHoursId
    : [SELECT Id FROM BusinessHours WHERE IsDefault = true LIMIT 1].Id;

Datetime expected = BusinessHours.add(bhId, c.CreatedDate, (Long) minutesToEscalation * 60 * 1000);
System.debug('Case ' + c.CaseNumber + ' should escalate on or after ' + expected);
```

`BusinessHours.add` takes milliseconds of business time; the fallback to the default calendar matters because `BusinessHoursId` is null on most cases until something populates it. Method signatures are in `admin/business-hours-and-holidays`.

**Why it works:** The escalation engine counts only hours that fall within the 8 AM–6 PM Monday–Friday window. A case created at 5 PM Friday has 1 hour of business time that day. It needs 7 more hours after 8 AM Monday — meaning escalation fires around 3 PM Monday. The notification lands when someone is actually available to act.

---

## Anti-Pattern: Multiple Active Escalation Rules for Different Case Types

**What practitioners do:** Attempt to create two escalation rules — one for "Sales Cases" and one for "Service Cases" — believing both will be active simultaneously to handle different SLA requirements.

**What goes wrong:** Salesforce only allows one active escalation rule per org. When you activate the second rule, the first is automatically deactivated. One set of cases stops escalating without any error message. The deactivation happens silently — there is no warning in the UI that the previous rule was turned off.

**Cheapest detection:** count the active flags in source before the deploy leaves your machine.

```bash
grep -c '<active>true</active>' \
  force-app/main/default/escalationRules/Case.escalationRules-meta.xml
# 1 = one live rule. 2 or more = the deploy is a silent cutover.

python3 skills/admin/escalation-rules/scripts/check_escalation_rules.py \
  --manifest-dir force-app/main/default
```

Exit 1 means an ERROR: two active rules, an active rule with no entries, a
`minutesToEscalation` that is not a positive integer, or an `assignedTo` naming
a queue or user this manifest does not contain. WARN and INFO lines print and
exit 0 — point `--manifest-dir` at the whole package, not just the
`escalationRules` folder, so the queue and user files are there to resolve
against.

**Correct approach:** Use a single active escalation rule with multiple rule entries that differentiate by criteria. Entry 1: `Type = Sales Case` with Sales SLA thresholds. Entry 2: `Type = Service Case` with Service SLA thresholds. Both sets of criteria live within the one active rule, and each entry can have its own escalation time and actions.
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall