//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
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.
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.
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.
[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
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?
//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
Hi Laxami,
This is the code:
Here is debug log:
"International - Escalations" was my queue name.
All Answers
Hi Lakshmi,
Try to use following SOQL query.
SOQL Query:
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/
This query useful for display queues names in organaisation but i want for currentloginuser of queue names only.Pls pls help me for this
Hi,
Try to use following SOQL query.
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/
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.
[Select Group.Name from GroupMember where UserOrGroupId =: UserInfo.getUserId()];
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
Regards,
Bhavi Sharma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com
But i want display queue names based on role for current login user
Regards,
Bhavi Sharma
Certified Salesforce Consultant
bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com
+91-9928130589
LinkedIn |
Twitter
| Blog |
Community
www.simplyforce.com
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?
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
Bhawani Sharma,
Please give hope to me,pls help me this query and check once for correct one.
Thanks for your reply,
Please give solution as soon as possible .I think your understood my scenario clearly
Hi Laxami,
This is the code:
Here is debug log:
"International - Escalations" was my queue name.
Thank you so much,
Can U modify this query for working for both user and role as queue member.