Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Reference qualifier advance

tylerduren7
Tera Contributor

Create a catalog item withe following details:
Item name : Add User to a Group
Variables:
1. Please select the user. ( it should show list of all the active users so that we can select one )
2. Select the Group. ( it should be showing all the active groups where the user is not already member of it )

 

Please give me solution for this

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@tylerduren7 

do this

1) 1st variable add this reference qualifier -> active=true

2) add this in 2nd variable ref qualifier

javascript:'sys_idNOT IN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.variables.firstVariable).getMyGroups());

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

16 REPLIES 16

Sunny3008
Tera Guru

Hello @tylerduren7 ,

 

1. For user variable use advance reference qualifier 

active=true

2. for group variable use advance reference qualifier  

sys_idNOT INjavascript:gs.getUser().getMyGroups()

replace ":" with ":" in query.

 

If my answer helps you mark this as correct and helpful.

 

Thanks
Sunny

Hello @tylerduren7 ,

 

you can try like following which is worked for me.

 

sys_idNOT INjavascript:gs.getUser().getUserByID(current.variables.please_select_user).getMyGroups();

replace :  with ":"

 

Thanks,
Sunny R

Screenshot 2025-06-19 115426.pngScreenshot 2025-06-19 115443.pngScreenshot 2025-06-19 115501.png

Didn't work where user George is already in four groups still reflecting 51 groups 

Chaitanya ILCR
Giga Patron

Hi @tylerduren7 ,

 

on the 1. please select the user variable add filter like this

 

ChaitanyaILCR_3-1750265634280.png

 

 

on the 2. Select the Group

 

javascript:'active=true^sys_idNOT IN'+Array.from(gs.getUser().getUserByID(current.variables.please_select_the_user).getMyGroups())

it's javascript:  not javascript:

refer the screenshots

Note: in the above line update(please_select_the_user ) with the name of 1st variable (please select the user) if the name is different 

ChaitanyaILCR_0-1750265729668.png

 

ChaitanyaILCR_1-1750265865155.png

 

 

Incase of any issues please share screenshots of your variable records

share 4 screenshots 2 for question section's

2 of Type specifications section's

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya