function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anas AlamourAnas Alamour 

Report on Queues and user members

I am trying to generate report on Queues and thier user members info as next :

Queue name , Queue email , Supported Objects , User full name 

i know this is not possible from Salesforce Reports direclty . so need to query  the three tables : Group , GroupMember , User using SOQL

Can anyone help me how to do that using Apex code ? 

 
VinayVinay (Salesforce Developers) 
Hi Anas,

Check below reference that has a workaround to report on queues and members.

https://salesforce.stackexchange.com/questions/175895/how-can-i-create-report-on-queues-and-queue-members
https://trailblazers.salesforce.com/answers?id=9063A000000Zt9gQAC

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Jonathan AdlersteinJonathan Adlerstein
I wrote this apex to get a distinct list of email addresses for members or the named queues. I execute it from the developer console (execute anonymous), and it can be easily modified to be incorporated in a class instead.
 
List<GroupMember> groupMemberList = new List<GroupMember>([SELECT UserOrGroupId FROM GroupMember WHERE Group.Name IN ('Case Approvers')]);
Set<Id> userIdSet = new Set<Id>();
for (GroupMember eachMember : groupMemberList) {
    userIdSet.add(eachMember.UserOrGroupId);
}

List<User> users = new List<User>([SELECT Email FROM User WHERE Id IN :userIdSet]);

Set<String> emailSet = new Set<String>();
for (User eachUser : users) {
    emailSet.add(eachUser.Email);
}

system.debug(emailSet);