- 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:14 AM
Hello @Jay N
You have not added the line
ga.addParam('sysparm_name','getGroupMembers');
Also whole setting the value for the field, pass users.toString() and not only users.
Please try above two things and let me know if this works for you.
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=0WynLcOw
NeEISQCY
- 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:50 AM
Thanks Sunil,
This code worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 05:54 AM
Hello @Jay N
I have also given same modifications just haven't shared code. Is it in anyway working for you ?
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