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.
  • ManagerPublic group that includes a user’s direct and indirect managers. This Group is read-only.
  • ManagerAndSubordinatesInternalPublic 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.

(1260)

Written by 

I am Sakthivel Madesh, a certified Salesforce Developer & Administrator working on Salesforce Technology since 2011. I am currently working in IBM Austraila as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 10 Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply