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.

Autopopulate Group name when user is selected in requested for

kamlesh
Tera Contributor
 
12 REPLIES 12

i am creating a catalog form and  requested for is a variable and when any user is selected then in the My group variable it will show the list of groups which i am member. and currently i am using reference type and sys_user_group is the reference .please guide me @Ankur Bawiskar 

@kamlesh 

You need to do this

I assume group variable is reference type and not list collector

1) add this in the advanced ref qualifier on group variable

javascript: 'sys_idIN' + global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.variables.requested_for).getMyGroups());

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

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

Its is still showing all the groups not the one i am member of.

Danish Bhairag2
Tera Sage

Hi @kamlesh ,

 

One way would be to write a client script & script include to getch all the groups user is part of then using addOptions in client script populate the field My group membership if its a select box type.

Else

U can write the below thing in reference qualifier under type specification of My Group membership variable

DanishBhairag2_0-1703078672941.png

javascript:user='+current.variables.requested_for

 

Thanks,

Danish

 

It is showing created dates in the list .