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
luccilucci 

Queues names diplay

I need to display  whatever access queues names  for current login user,

 

Please anybody help me for this

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma

Hi Laxami,

 

This is the code:

//Groups related to current user's role
List<Group> roleGrps = [Select Id from Group where Type='Role' AND RelatedId= : UserInfo.getUserRoleId()];

for(GroupMember grpM : [Select Group.Name from GroupMember where UserOrGroupId IN: roleGrps])
	System.debug('Queue Name: ' + grpM.Group.Name);

 

Here is debug log:

Execute Anonymous: 
Execute Anonymous: for(GroupMember grpM : [Select Group.Name from GroupMember where UserOrGroupId IN: roleGrps])
Execute Anonymous: 	System.debug('Queue Name: ' + grpM.Group.Name);
02:03:10.071 (71627000)|EXECUTION_STARTED
02:03:10.071 (71641000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
02:03:10.072 (72791000)|SOQL_EXECUTE_BEGIN|[2]|Aggregations:0|select Id from Group where (Type = 'Role' and RelatedId = :tmpVar1)
02:03:10.086 (86149000)|SOQL_EXECUTE_END|[2]|Rows:1
02:03:10.086 (86539000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select Group.Name from GroupMember 
02:03:10.104 (104526000)|SOQL_EXECUTE_END|[4]|Rows:1
02:03:10.104 (104797000)|SYSTEM_METHOD_ENTRY|[7]|QueryLocatorIterator.QueryLocatorIterator()
02:03:10.104 (104811000)|SYSTEM_METHOD_EXIT|[7]|QueryLocatorIterator
02:03:10.105 (105254000)|USER_DEBUG|[5]|DEBUG|Queue Name: International - Escalations
02:03:10.089 (105344000)|CUMULATIVE_LIMIT_USAGE
02:03:10.089|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 2 out of 100

 

"International - Escalations" was my queue name.

All Answers

hitesh90hitesh90

Hi Lakshmi,

 

Try to use following SOQL query.

 

SOQL Query:

Select Name, Id From Group where Type = 'Queue'

 

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

luccilucci

This query  useful for  display queues names in organaisation but i want for currentloginuser of queue names only.Pls pls help me for this

 

 

 

hitesh90hitesh90

Hi,

 

Try to use following SOQL query.

 

List<Group> lstGroup = [Select Name, Id From Group where Type = 'Queue' and OwnerId =: system.userinfo.getuserid()];

 Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

luccilucci

Hi hitesh,

 

 Its working but  if  that user not in queue  ,then that queue name also display.this is the pro ,i faced by using this query .If you dont mind check once and let me know the correct query.

 

 

Bhawani SharmaBhawani Sharma

[Select Group.Name from GroupMember where UserOrGroupId =: UserInfo.getUserId()];

luccilucci

Hi Bhawani Sharma,

 

Here I am faced some problem ,In that queue ,queuemember assigned as role not user.so How can I get queue names for currentloginuser based on role.

 

 

Thanks

Lakshmi

Bhawani SharmaBhawani Sharma
[Select Name from Group where Type='Role' and relatedId = User.userRoleId];
Bhawani SharmaBhawani Sharma
[Select Name from Group where Type='Role' and relatedId = User.userRoleId];
Regards,
Bhavi Sharma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com
luccilucci

But i want display queue names  based on role for current login user

Bhawani SharmaBhawani Sharma
Query current user role id and replace it " User.userRoleId" here.

Regards,
Bhavi Sharma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com
luccilucci

Can u pls tell me the total query  for getting Queues names for currentloginuser ,but here login user not directly as queue member,role is a queue member,so how i can get?

Bhawani SharmaBhawani Sharma
[Select Name from Group where Type = 'Role' and RelatedId =: UserInfo.getUserRoleId()];
luccilucci

Its not working,pls check its once ,one  role as added into queue,then try for this for display queue names for current login user

luccilucci

Bhawani Sharma,

 

Please give hope to me,pls help me this query and check once for correct one.

Bhawani SharmaBhawani Sharma
I will get back to you on this soon.
luccilucci

Thanks for your reply,

 

Please give solution as soon as possible .I think your understood my scenario clearly

Bhawani SharmaBhawani Sharma

Hi Laxami,

 

This is the code:

//Groups related to current user's role
List<Group> roleGrps = [Select Id from Group where Type='Role' AND RelatedId= : UserInfo.getUserRoleId()];

for(GroupMember grpM : [Select Group.Name from GroupMember where UserOrGroupId IN: roleGrps])
	System.debug('Queue Name: ' + grpM.Group.Name);

 

Here is debug log:

Execute Anonymous: 
Execute Anonymous: for(GroupMember grpM : [Select Group.Name from GroupMember where UserOrGroupId IN: roleGrps])
Execute Anonymous: 	System.debug('Queue Name: ' + grpM.Group.Name);
02:03:10.071 (71627000)|EXECUTION_STARTED
02:03:10.071 (71641000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
02:03:10.072 (72791000)|SOQL_EXECUTE_BEGIN|[2]|Aggregations:0|select Id from Group where (Type = 'Role' and RelatedId = :tmpVar1)
02:03:10.086 (86149000)|SOQL_EXECUTE_END|[2]|Rows:1
02:03:10.086 (86539000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select Group.Name from GroupMember 
02:03:10.104 (104526000)|SOQL_EXECUTE_END|[4]|Rows:1
02:03:10.104 (104797000)|SYSTEM_METHOD_ENTRY|[7]|QueryLocatorIterator.QueryLocatorIterator()
02:03:10.104 (104811000)|SYSTEM_METHOD_EXIT|[7]|QueryLocatorIterator
02:03:10.105 (105254000)|USER_DEBUG|[5]|DEBUG|Queue Name: International - Escalations
02:03:10.089 (105344000)|CUMULATIVE_LIMIT_USAGE
02:03:10.089|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 2 out of 100

 

"International - Escalations" was my queue name.

This was selected as the best answer
luccilucci

Thank you so much,

Can U modify this query for working for both user and role as queue member.