5

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?

5
  • 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
    Apr 14, 2016 at 6:25
  • 4
    Possible duplicate of Query all queues I am a member of 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. 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. 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. Apr 14, 2016 at 7:00

2 Answers 2

6

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.

0

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:

SELECT
    id, name, username, isActive
FROM
    user
WHERE
    id IN ( SELECT userOrGroupId FROM groupmember WHERE groupId = :groupId )
ORDER BY
    name
1
  • 1
    The filter on your inner join should be Group.Type = 'Queue', not a bind variable on GroupId.
    – Adrian Larson
    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 .