How can I query all the queues to which a user belongs?

Note: Queues also contains public groups, role, role and subordinate and I need to loop through all these to find out if user is associated with these also.

Also I found out in user related list there is something called "queue membership" which contains all the queues that user associated with. Which object do I query for this?

  • you will be more likely to get an answer if you show us what have you already tried. If you just want somebody to write code for you, please consider hiring a developer. We will gladly help you with your problems/bugs/errors, but only if you show us some of your own effort
    – Novarg
    Commented Apr 14, 2016 at 6:25
  • 4
    Possible duplicate of Query all queues I am a member of Commented Apr 14, 2016 at 6:28
  • @Novarg : I don want anyone to write code for me as i have already tried a lot and got stuck with roles, subordinate and public groups present inside the queue.I can loop through all of these but was looking for a simple approach/workaround. Commented Apr 14, 2016 at 6:38
  • @VigneshwaranG : I have already tried the link u posted but it wont give me the users inside the role, roles and subordinate and pubic groups. So possible its a not a dublicate question. Commented Apr 14, 2016 at 6:41
  • I agree. Retracted my close vote. Just checked it with me being available in Public Group and added this Public Group into a Queue as only member. When i used this query it returns 0 records but i could see that Queue under my User details. Commented Apr 14, 2016 at 7:00

2 Answers 2


The Sobject you should query is GroupMember. But it have the membership details of both Queue and Public Group. So you need to differentiate it using the Group type as 'Queue'.

Select Group.Name from GroupMember where UserOrGroupId = 'userid' and Group.Type = 'Queue'

Note: If the user is not added to the Queue directly this query won't work. Ex: If you add the user to Public Group and add this Public Group to the Queue, this query will return 0 results.

Hope it helps.


You may find this Github repo from Doug Ayers very helpful and pertinent.

As of this writing, Salesforce provides no way of reporting on who belongs to which queues.

The only workaround is to use SOQL to query users that belong to known groups by joining on groupmember object:

    id, name, username, isActive
    id IN ( SELECT userOrGroupId FROM groupmember WHERE groupId = :groupId )
  • 1
    The filter on your inner join should be Group.Type = 'Queue', not a bind variable on GroupId.
    – Adrian Larson
    Commented Nov 29, 2017 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .