- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 05:04 AM
Hi Experts,
We have requirement to populate group members to a field when assignment group is changed or form loaded, this is on native UI Form. I tried client script and script include but users are not populated.
Request to share your inputs
Script include: GetGroupMembers
Client callable = True
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 05:17 AM
Please try with below updated code:
var GetGroupMembers = Class.create();
GetGroupMembers.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getGroupMembers: function() {
var groupId = this.getParameter('sysparm_sys_id'); // Fix parameter retrieval
var userList = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', groupId);
gr.query();
while (gr.next()) {
userList.push(gr.user.toString());
}
return userList.join(',');
}
});
Client script:
// Get the assignment group
var assignmentGroup = g_form.getValue('u_iso_group');
if (assignmentGroup) {
// GlideAjax to call a Script Include
var ga = new GlideAjax('GetGroupMembers');
ga.addParam('sysparm_name', 'getGroupMembers'); // Mandatory function name
ga.addParam('sysparm_sys_id', assignmentGroup); // Correct parameter name
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('u_iso_group_members', response); // Use response directly
} else {
g_form.setValue('u_iso_group_members', '');
}
});
} else {
g_form.setValue('u_iso_group_members', '');
}
Please mark correct/helpful if this helps you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 05:19 AM
Hello @Jay N
Also for passing the sys_id parameter , please use - sysparm_sys_id and same this.getParameter - call it the same way.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
If these don't work please share full screenshots of both.