+ Start a Discussion
Santosh reddy 14Santosh reddy 14 

How to retrieve a queue using SOQL query

Best Answer chosen by Santosh reddy 14
Amit Singh 1Amit Singh 1
Hello,

Queues are stored into Group Objects in Salesforce and Users that are present are being stored into GroupMember Object.

Use below SOQL Queries.

For All the Queues into Salesforce Org.
select Id from Group where Type = 'Queue'

For Quering specific Queue.
select Id from Group where  Type = 'Queue' AND NAME = 'QueueName'
// You can also use DeveloperName so that if you have used Queue Name Developer Name Will be same SOQL will be like

select Id from Group where Type = 'Queue' AND DeveloperNAME = 'Test_Queue' // If QueueName is Test Queue the developer Name will be Test_Queue

If you want to query public groups/quques then use below SOQL.
select Id from Group where Type = 'Public' AND Developer_Name='Test_Group'

Please let us know if this helps :)

Thanks,
AMit Singh


 

All Answers

fred flores 20fred flores 20
SOQL is not the native language that can be found in Salesforce. It is used as part of Apex for developer to create queries therefore you need to be using the tools like Developer Console to use SOQL to create the query and begin back the results. If you want to experiment on this area I suggest you try out Trailhead. The exercies below will give you a starting point.

https://trailhead.salesforce.com/modules/apex_database/units/apex_database_soql
v varaprasadv varaprasad
Hi Santhosh,


please check below code.

If you substitute the user's id for xxxxxxxxxx you will get a list of all Queues that user belongs too
select GroupId, Group.Name from GroupMember where UserOrGroupId = 'xxxxxxxxxx'
To get all of the queues available, you can query with the following.
select Name from Group where Type = 'Queue'

let me know if you need any details.


Thanks
Varaprasad
 
Nitesh K.Nitesh K.
Queues are stored as a Group SObject, so
select Id from Group where  Type = 'Queue'
if you want specific queue in SOQL
select Id from Group where Name = 'QueueName' and Type = 'Queue'


Let me know if this helps.
Amit Singh 1Amit Singh 1
Hello,

Queues are stored into Group Objects in Salesforce and Users that are present are being stored into GroupMember Object.

Use below SOQL Queries.

For All the Queues into Salesforce Org.
select Id from Group where Type = 'Queue'

For Quering specific Queue.
select Id from Group where  Type = 'Queue' AND NAME = 'QueueName'
// You can also use DeveloperName so that if you have used Queue Name Developer Name Will be same SOQL will be like

select Id from Group where Type = 'Queue' AND DeveloperNAME = 'Test_Queue' // If QueueName is Test Queue the developer Name will be Test_Queue

If you want to query public groups/quques then use below SOQL.
select Id from Group where Type = 'Public' AND Developer_Name='Test_Group'

Please let us know if this helps :)

Thanks,
AMit Singh


 
This was selected as the best answer