- 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
‎12-19-2022 10:38 AM
Hi @Ankur Bawiskar ,
I tried following this post, but cannot get it to work. Looking at my script include and client script. Do you spot anything I did wrong?
var reqUtilsAjax = Class.create();
reqUtilsAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroupMembers: function() {
var grpID = this.getParameter('sysparm_gid');
var memObj = new GlideRecord('sys_user_grmember');
memObj.addQuery('group', grpID);
memObj.query();
var nArray = [];
var vArray = [];
while (memObj.next()) {
nArray.push(memObj.user.getDisplayValue().toString());
vArray.push(memObj.user.toString());
}
var retValue = nArray.toString() + '|' + vArray.toString();
return retValue;
},
type: 'reqUtilsAjax'
});
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.setValue('members', '');
var ga = new GlideAjax('reqUtilsAjax');
ga.addParam('sysparm_name', 'getGroupMembers');
ga.addParam('sysparm_gid', 'newValue');
ga.getXML(buildList);
}
function buildList(response) {
var answer = response.responseXML.documentElement.getAttribute("asnwer");
var memArray = answer.split('|');
var memNames = memArray[0];
var memValues = memArray[1];
g_form.setValue('members',memValues);
//Type appropriate comment here, and begin script below
}
One Reference field for my sys_user_groups and the List Collector for my sys_user.