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

Kunal Varkhede
Tera Guru

Hi,

 

You could set the glide_list attribute on the List collector to make it behave like a normal platform List field. Once the attribute is set, you can set comma separated sys_id's of users directly using g_form.setValue('') without any complex scripting in it. Also it will work on service portal as well.

ie g_form.setValue('list_field' , '1,2,3,4,5'); // comma separated sys_id's of user.

 

Thanks,

Kunal

Hi Kunal, thanks for responding ..


Yeah, you're right, that can be done and would make the task at hand a bit easier. But I also want the end-users to be able to add users to the group .. which I thought I would do by using the list collector.  I mean I'll have the list of all the users on the left and the group members on the right ..

Is there someway we could achieve this using the glide_list as well ?

 

Also, the most important thing I want to ask here is;

How do I populate the list of users of a selected group ? 😞 I'm unable to do so !

harshav
Tera Guru

Hi Akash,

Here you need to write an onchange client script, and a script include to do server side call. In the server side code send the value of sys_id's in a comma separated string. Now in the client script call back function set the value that you got from server.

Thanks

SreeHarsha 

Hi Harshav, thanks for the guidance, I understand we may need to follow this path. However, I'm unable to fetch list of group members from a group ! 😞