Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Assignment group for logged in user

miro2
Mega Sage

Hi,

I want to display only those groups in the 'Assignment group' field where the logged-in user is a member. I tried using the following script in the HR Template on HR Service, but it didn't work. 
 javascript:'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());

 

Does anyone have suggestions on how to display groups specific to the logged-in user in the 'Case Creation' section?

miro2_0-1693252257310.png

miro2_1-1693252399311.png

 

12 REPLIES 12

Yes 'javascript:' is an outstanding syntax issue with the community forums, when you add code.

Edited as plain text is also converted incorrectly.
Your entry should be 'javascript' and a colon with no spaces , followed by you refqual condition

TonyChatfield1_0-1693258624865.png

 

that's what I did, I used javascript and colon symbol 

111.jpg

 

 

also when I checked this in background script I got array with comma separated sysids

gs.info(gs.getUser().getMyGroups().toString());

 

miro2_1-1693259300921.png

 

even if I used 

new global.ArrayUtil().convertArray(gs.getUser().getMyGroups())

instead of

gs.getUser().getMyGroups().toString()

 it still doesn't work with syntax javascript: 

in background when printing  gs.info(new global.ArrayUtil().convertArray(gs.getUser().getMyGroups()));

I got sysids comma separated but without array

miro2_2-1693259663177.png

 




Sorry, small error on my part, 'sys_id' needs to be 'assignment_group' as it's the sys_id of the assigment group we are filtering for.