Populate the list of group members in a list collector as per the group selected in a reference field above

AkashD
Kilo Expert

Hey folks,

I have a requirement for a catalog item where I need to populate the list of group members in the right bucket of the list collector as per the group selected in a reference field above.

The form looks like this as of now :

find_real_file.png

The first field is reference to "sys_user_group" while the list collector is showing the users with a simple reference qualifer which says "active=true^user_name!=empty".

What I'm basically trying to achieve is to edit the group members (add or remove) using this form; I know that could later be achieved via the workflow, but as of now I'm struggling with this. I've tried plenty of scripts available in the community, but none of them seem to be working for me. 

Any slight help would be really appreciated! Thanks in advance!

1 ACCEPTED SOLUTION

@Ankur Bawiskar,

The code which I'm trying is below :

Client Script :

group_members is the name of the list collector

find_real_file.png

 

Script Include :

find_real_file.png

 

Any slight help would be highly appreciated, thanks!

View solution in original post

15 REPLIES 15

@AkashD 

So based on group selected you need to auto push the group members to right side

you would require onchange client script on Group variable for this and combination of Script Include and GlideAjax

Please share your current code

Below blog/article has info on how to set right side value based on change of variable

Dynamically set list collector on change of variable

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

 

 

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

@Ankur Bawiskar,

The code which I'm trying is below :

Client Script :

group_members is the name of the list collector

find_real_file.png

 

Script Include :

find_real_file.png

 

Any slight help would be highly appreciated, thanks!

Hi,

Did you try adding alert what you are getting from script include?

alert(answer);

there is error in your client script; you are not using valid array after split

var memNames = memArray[0];

var memValues = memArray[1];

Also where is this not working? in native or portal?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Ankur, nothing's coming up in alert! You may have a look below :

find_real_file.png

 

Hi,

issue in your script include; you need to use variable grpID

memObj.addQuery('group', grpID);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

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