Sub topic 5
Creating and Managing Queues
This chapter assumes you can navigate Setup, know what an object and a list view are, and understand profiles and permission sets. The Apex and SOQL sections assume you can read simple code. You do not need to write it to follow the rest.
A queue is a shared holding place for records. Cases in a queue are owned by the group, not by one person, until an agent picks them up. This chapter covers how to create a queue, how to choose its members, how agents work with queued cases, and the errors people hit most often.
What a queue is
A queue is a named group of users, roles, or other groups that can take ownership of records of one or more object types. For cases, a queue lets a team share one backlog. Any member can open the queue, find a case, and take it.
Under the hood, a queue is stored as a Group record whose Type is Queue. That is why you can assign its Id to a case's OwnerId field, as in the Apex section later. The previous chapter explained that OwnerId can hold a user or a queue. This chapter covers the queue side of that rule.
Two facts shape everything else:
- A queue is not a user. It cannot log in, own a license, or be mentioned in the same way a person can.
- A case in a queue is still owned.
OwnerIdis never empty. It holds the queue's Id.
Creating a queue
Create a queue in Setup. Search for Queues in Quick Find, then choose New.
- Label and Queue Name. The label is what users see. The queue name is the API name, also called
DeveloperName. Choose it carefully, because Apex and metadata refer to it. Use a clear, stable name such asTier2_Support. - Queue Email. Optional. Salesforce sends notifications about new queue records to this address.
- Send Email to Members. If selected, Salesforce emails each member when a record is assigned to the queue. In a large queue this can create a lot of email, so use it with care.
- Supported Objects. Select Case. A queue can only own records of the objects you list here. If Case is missing, the queue cannot be chosen as a case owner.
- Queue Members. Add users, public groups, roles, or roles and subordinates.
Save the queue. It is ready to use for manual assignment right away. It does not receive new cases automatically until an assignment rule, Apex, or another automation points to it.
Choosing members
Membership controls who can see the queue as an owner and take its records. Salesforce lets you add several kinds of members:
| Member type | What it includes | Typical use |
|---|---|---|
| User | One named user | A small team or a specialist |
| Public group | Any users, roles, or groups in that group | Reusing a team list across queues |
| Role | Users in exactly that role | Teams defined by hierarchy position |
| Role and Subordinates | The role and every role below it | A manager and the whole team |
Members can be added from a mix of these types. Salesforce expands them to individual users when it checks access.
Keep in mind these points:
- A queue member who has no access to the Case object still cannot work cases. Queue membership does not grant object permissions. The user's profile or permission sets must include at least Read and Edit on Case.
- Sharing rules still apply. If your organization-wide default for Case is Private, queue members can see cases owned by their queue. They do not automatically see cases owned by other queues.
- Roles above a queue member can usually see the queue's records through the role hierarchy, if the object grants access using hierarchies.
How agents work with queued cases
A queue is only useful if agents can find and claim cases from it.
Case list views
Open the Cases tab and pick a list view. Standard list views include queue-based ones, and you can create your own with a filter such as Owner equals your queue name. Every queue also appears in the owner filter of list views as "Queue" entries, so an agent can select the queue name and see its backlog.
In Lightning Experience, an agent can select one or more cases in the list view and choose Accept. This changes the owner from the queue to that agent. An agent can also use Change Owner to give a case to another user or queue.
Taking and moving cases
- Accept. Available when the case is owned by a queue and the agent is a member. It sets
OwnerIdto the agent. - Change Owner. Available to users who have edit access to the case. They can pick a user or a queue. The queue must support Case.
- Return to queue. Done by changing the owner back to the queue. There is no separate undo.
Accepting does not change Status. If you want a case to move from New to Working when someone takes it, add automation such as a flow or validation to do that. This is a common surprise.
Notifications
If you enabled Send Email to Members, members receive an email at assignment. Queue Email, if set, receives it instead of or in addition to individual members, depending on how you configured the queue. Test with a small queue first, because notification settings are the most common reason people complain about noisy inboxes.
Visualizing the flow
The diagram shows how a case sits in a queue and moves to an agent.
Managing queues over time
A queue needs upkeep. Teams change, and old queues pile up.
- Review membership. Check queues when people change roles. A user who left a team may still receive email or still be able to claim cases.
- Rename with care. You can change the label safely. Changing the queue name (
DeveloperName) can break Apex, flows, or deployed metadata that refer to it. - Remove with care. You cannot delete a queue that still owns records. First reassign the cases, then delete the queue. Deleting a queue that assignment rules or escalation rules still point to leaves those rules with an invalid target. Update the rules first.
- Deactivate by emptying. Salesforce has no "inactive" flag for queues. To retire one, remove its supported objects or members only after you have moved its cases and removed it from rules.
Queues and deployment
Queues are metadata. You can move them between sandboxes and production with change sets or the Metadata API as Queue components. Membership may be included, but referenced users and groups must exist in the target org. Check this before you deploy, or the deployment can fail.
Working with queues in code
Because a queue is a Group, you look it up by DeveloperName and Type. Do not hard-code the Id. Ids differ between sandbox and production.
Group tier2 = [
SELECT Id
FROM Group
WHERE Type = 'Queue' AND DeveloperName = 'Tier2_Support'
LIMIT 1
];
Case c = new Case(
Subject = 'Data export fails',
Origin = 'Email',
OwnerId = tier2.Id
);
insert c;If the query returns no row, Apex throws a QueryException on assignment of an empty list. In production code, query into a list and check that it is not empty before you use it.
To see what a queue still holds, use SOQL. This finds open cases that no individual agent has taken yet:
SELECT Id, CaseNumber, Subject, Status
FROM Case
WHERE Owner.Type = 'Queue' AND IsClosed = false
ORDER BY CreatedDate ASCThe oldest cases come first. If the top of this list is days old, the queue has a staffing or visibility problem.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Queue does not appear when choosing a case owner | Case is not a supported object for the queue | Edit the queue and add Case under Supported Objects |
| Agent cannot see the queue's cases | Agent is not a member, or lacks Case object access | Add the agent or their group, and check profile or permission sets |
| Agent can see cases but cannot accept them | Not a direct or indirect member, or no Edit access | Verify membership and the Edit permission on Case |
| Cannot delete a queue | Queue still owns records, or is referenced by a rule | Reassign cases and update rules, then delete |
| Apex fails to find the queue | Wrong `DeveloperName`, or the queue was renamed | Query by the current API name and handle empty results |
| Members get too many emails | Send Email to Members is on | Turn it off, or use a Queue Email address instead |
Exercises
Exercise
A new queue named Billing_Support exists and has members, but it is missing from the owner choices when you change the owner of a case. What is the most likely cause, and how do you fix it?
Show answer
Case is probably not listed under the queue's Supported Objects. Edit the queue in Setup, add Case to Supported Objects, and save. The queue then appears as a possible case owner.
Exercise
Write a SOQL query that returns open cases owned by any queue, and say what a long list of old results tells you.
Show answer
SELECT Id, CaseNumber, Subject, Status FROM Case WHERE Owner.Type = 'Queue' AND IsClosed = false ORDER BY CreatedDate ASC. Old results mean cases are waiting without an agent, which points to understaffing, missing notifications, or members who cannot see or accept the cases.