- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2020 11:28 AM
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 :
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 01:14 AM
The code which I'm trying is below :
Client Script :
group_members is the name of the list collector
Script Include :
Any slight help would be highly appreciated, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 03:24 AM
Wow You have a keen eye for detail
I just fixed that, and upon putting an alert with answer, I'm getting the list of users of the selected group and their sysID seperated by a '|'. The users and sysID themselves are separated by a comma! Somewhat like -
user_name1,user_name2,user_name3|sysID1,sysID2,sysID3
In the code, I have used :
g_form.setValue('group_members',memValues,memNames);
This is the last step which is not working I guess. Do we have some alternative to this ? I hear this part of the code needs to be different in portal and legacy ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 03:32 AM
Hi,
for portal you can directly set sys_ids as below
g_form.setValue('group_members', memValues);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 03:41 AM
Hi,
if you need solution working for both native and portal below link you can refer
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 12:27 PM
Hi Akash did it work...I am in the same step...listcollector is not autopopulating?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2020 09:51 AM
Did you find solution to your query as I could see you marked answer as correct?
It looks like you marked your own response as the correct answer, which may be confusing to others that read this later.
Do you still require assistance on this?
If yes then please correct this line; it should work in portal
g_form.setValue('group_members', memValues);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader