Sub topic 1
What a Case is and which fields matter
A Case in Salesforce records one customer issue, question, or request from the moment it is reported until it is resolved. This chapter covers the Case object, the fields that drive routing and escalation, and how Case relates to other objects. Later chapters build on these fields.
Prerequisites
This chapter assumes you can do the following:
- Navigate Setup, open the Object Manager, and read an object's field list.
- Explain what users, profiles, and permission sets are.
- Describe a basic support workflow: a customer reports a problem, an agent works on it, and the agent closes it.
- Optional: read simple SOQL queries. The code samples here are short.
What a Case represents
A Case is a standard object in Salesforce. Each record tracks one support request. The record holds the customer's description of the problem, who is working on it, how urgent it is, and how far along it is.
Think of a Case as a ticket. Everything the support team does about an issue is attached to it: emails, comments, files, tasks, and a history of changes. Because the Case is the unit of work, queues, assignment rules, and escalation rules all operate on Case records.
A standard object is one that ships with Salesforce and is not created by your admin. Case has many built-in fields, and you can add custom fields to it.
Fields that matter for routing and escalation
Case has dozens of fields. A handful decide where a case goes and how long it can stay there. The table lists them by their API names, which you use in SOQL and Apex.
| Field label | API name | Type | Why it matters |
|---|---|---|---|
| Case Number | `CaseNumber` | Auto-number | Human-readable identifier. Read-only. |
| Subject | `Subject` | Text | Short summary. Often used in rule criteria. |
| Description | `Description` | Long text | Full problem statement. |
| Status | `Status` | Picklist | Position in the lifecycle. Controls `IsClosed`. |
| Priority | `Priority` | Picklist | Urgency. Common criterion in assignment and escalation. |
| Origin | `Origin` | Picklist | Channel that created the case, such as Web or Email. |
| Type | `Type` | Picklist | Category, such as Problem or Question. |
| Reason | `Reason` | Picklist | Why the customer got in touch. |
| Owner | `OwnerId` | Lookup (User or Queue) | Who is responsible right now. |
| Contact | `ContactId` | Lookup | The person who raised the issue. |
| Account | `AccountId` | Lookup | The customer organization. |
| Is Closed | `IsClosed` | Checkbox | True when the status is a closed status. Read-only. |
| Is Escalated | `IsEscalated` | Checkbox | True when an escalation rule or a user escalated the case. |
| Created Date | `CreatedDate` | Date/Time | The starting point for age-based escalation. |
| Closed Date | `ClosedDate` | Date/Time | Set when the case closes. |
Some of these fields deserve a closer look.
Status and IsClosed
Status is a picklist, and each value is marked as open or closed in Setup. IsClosed is not something you set directly. Salesforce sets it to true when Status changes to a value flagged as closed. This is why you filter open work with IsClosed = false instead of listing every open status by name. If an admin adds a new open status later, your filter still works.
Priority
Priority is a picklist with the default values High, Medium, and Low. Many teams use it as a criterion for both assignment and escalation, for example "High priority cases that are still open after two hours." Because the values are picklist entries, your org may use different names. Check the actual values before you write rule criteria.
Origin
Origin records how the case was created. Typical values are Phone, Email, and Web. Email-to-Case and Web-to-Case set it for you. Manual entry leaves it to the agent, so it is less reliable for cases created by hand. A later chapter covers the channels in detail.
OwnerId
OwnerId is a polymorphic lookup. That means one field can point to more than one kind of record. It can hold the Id of a User or the Id of a Queue. This single field is what makes queue-based routing work, because assigning a case to a queue is the same operation as assigning it to a person: you set OwnerId.
You can tell which kind of owner a case has by looking at the Id prefix or by querying Owner.Type. A User Id starts with 005. A Group Id, which is how a queue is stored, starts with 00G.
IsEscalated
IsEscalated is a checkbox that marks a case as escalated. An escalation rule can set it when a case reaches the age limit in a rule entry. A user with the right permission can also set it by hand. The flag does not move the case by itself. Reassignment is a separate action in the escalation rule. This distinction matters when you troubleshoot, and the chapter on escalation actions returns to it.
CreatedDate
Age-based escalation counts time from a case's creation, or from the last time it was modified, depending on how the rule is set up. CreatedDate is set by the system and cannot be edited, which makes it a dependable baseline.
Relationships to other objects
A Case rarely stands alone. These relationships determine what the agent sees and what automation can use.
- Account and Contact.
AccountIdidentifies the customer organization.ContactIdidentifies the person. When you pick a contact, Salesforce can fill in the account. - Case comments.
CaseCommentrecords are notes on the case. They can be public, visible to the customer in a portal, or internal. - Emails.
EmailMessagerecords hold emails sent and received on the case. - Case history. Salesforce tracks changes to fields you choose to track, such as
StatusandOwnerId. The history is how you answer "who had this case and when." - Parent case.
ParentIdlinks a case to a parent case. Teams use it to group related cases under one incident.
The diagram shows the main relationships.
Record types and picklist values
Record types let one object behave differently for different groups of users. A support team might create one Case record type for technical issues and another for billing questions. Each record type can show a different page layout and offer different picklist values for Status or Type.
Record types matter for routing in two ways:
- Rule criteria can test
RecordTypeId, so billing cases can go to a billing queue. - Picklist values are limited per record type. A criterion that tests a value the record type does not offer will never match.
Creating a case and reading it back
The following Apex creates a case with the fields discussed above. It runs as shown in an Execute Anonymous window. Because no OwnerId is given, the case is owned by the running user.
Case c = new Case(
Subject = 'Cannot log in to the portal',
Origin = 'Web',
Priority = 'High',
Status = 'New'
);
insert c;
Case saved = [
SELECT CaseNumber, Status, IsClosed, IsEscalated, Owner.Name, Owner.Type
FROM Case
WHERE Id = :c.Id
];
System.debug(saved.CaseNumber + ' owned by ' + saved.Owner.Name
+ ' (' + saved.Owner.Type + '), closed=' + saved.IsClosed);The debug log shows the owner type as User, IsClosed as false, and IsEscalated as false. The Status value New exists in the standard picklist. If your org renamed it, use a value from your own picklist.
Note that insert c does not run the active assignment rule. Apex inserts skip assignment rules unless you pass DMLOptions. A later chapter shows how.
Common errors
These mistakes appear often when people start working with cases.
- Filtering on a status name instead of
IsClosed. The filter breaks when an admin adds or renames a status. - Writing criteria for picklist values that do not exist. Rule criteria compare text. A typo or a renamed value silently matches nothing.
- Assuming
IsEscalatedmoves the case. The flag only marks it. Ownership changes only if an escalation action reassigns it. - Treating
OwnerIdas always a user. Code that readsOwner.Emailfails or returns null when the owner is a queue, because a queue has no email field in the same way a user does. - Expecting assignment rules to run on every insert. They run for web and email channels and for manual entry when the box is checked. They do not run for Apex unless you request it.
Exercises
Exercise
A report must list every open case, no matter how many custom open statuses your admins add over time. Which field should the filter use, and why?
Show answer
Use IsClosed = false. Salesforce sets IsClosed from whether the current Status is flagged as closed, so the filter stays correct when open statuses are added or renamed.
Exercise
A case's OwnerId begins with 00G. What kind of record owns the case, and what happens if your code reads Owner.Email for it?
Show answer
A queue owns the case, because queues are stored as Group records whose Ids start with 00G. A queue has no user email field, so reading Owner.Email returns null or fails. Check Owner.Type first.
Exercise
A case was escalated, and IsEscalated is true, but it still belongs to the same agent. Does this mean the escalation rule failed?
Show answer
Not necessarily. IsEscalated only marks the case. The case changes owner only if the escalation rule entry includes a reassign action. Check the rule entry's actions.