8K
How do Query Queue Id, Name in Salesforce Apex?
Queues are stored as a Group SObject:
For Example:
Group groupDetail = [SELECT Id, Name, DeveloperName, Email, Type FROM Group where Type=’Queue’ And Name =’Spam’ limit 1];
SpamOwnerId = groupDetail.Id;
Here Type is Required and Type of the Group is One of the following values:
- Regular—Standard Public Group. When you create() a Group, its type must be Regular, unless a partner portal is enabled for the organization, in which case the type can be Regula or PRMOrganization
- Role—Public Group that includes all of the User records in a particular UserRole.
- RoleAndSubordinates—Public Group that includes all of the User records in a particularUserRole and all of the User records in any subordinateUserRole.
- Organization—Public Group that includes all of the User records in the organization. This Group is read-only.
- Case—Public group of users, members of a queue that can own a Case.
- Lead—Public group of users, members of a queue that can own a Lead.
- Manager—Public group that includes a user’s direct and indirect managers. This Group is read-only.
- ManagerAndSubordinatesInternal—Public Group that includes a user and the user’s direct and indirect reports. This Group is read-only.
- PRMOrganization—Public Group that includes all of the partners in an organization that has the partner portal feature enabled.
- Queue—Public Group that includes all of the User records that are members of a queue.
- Territory—Public Group that includes all of the User records in an organization that has the territory feature enabled.
- TerritoryAndSubordinates—Public Group that includes all of the User records in a particular UserRole and all of the User records in any subordinateUserRole.
- Collaboration—Chatter group.
Group Member details has been stored in GroupMember Standard Salesforce Object
GroupId – Group Id
UserOrGroupId – ID of the User or Group that is a direct member of the group.