How to select only users of a specific group into a reference field

RudhraKAM
Tera Guru

I am trying to show users from 2 groups for a reference field , Came across this article which is working If I use sys_id of one group but not working when used 2 groups , What am i doing wrong 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0831564

 

javascript:'active=true^sys_idIN'+getIDs("74b1b52d1b4bdd10320c535b234bcb1f","fcb1b52d1b4bdd10320c535b234bcb12"); function getIDs(grp){var m=GlideUserGroup.getMembers(grp);var ids=''; while (m.next()){ids+= (m.user+',');} return ids;}

 

 

1 ACCEPTED SOLUTION

RudhraKAM
Tera Guru

Fixed with other approch

 

In the Reference variable , Select group member table and use the group sysID , this will fix the issue 

RudhraKAM_0-1689942149935.png

 

 

View solution in original post

8 REPLIES 8

Rahul Talreja
Mega Sage
Mega Sage

Hi @RudhraKAM ,
For 2 groups. Please try below:

 

javascript:'active=true^sys_idIN'+getIDs("74b1b52d1b4bdd10320c535b234bcb1f","fcb1b52d1b4bdd10320c535b234bcb12"); function getIDs(grp1, grp2){var m1=GlideUserGroup.getMembers(grp1);var ids=''; while (m1.next()){ids+= (m1.user+',');}var m2=GlideUserGroup.getMembers(grp2); while (m2.next()){ids+= (m2.user+',');} return ids;}

 

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

Hello Rahul , This is showing all the users

All user means, Whole sys_user table?

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

I'm looking for the same solution and tried it out and yes, with your code it's showing all users from sys_user table.