- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 12:59 AM
Hello Community,
I want to show the group member in alert, can anyone tell me how to acheive this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:02 AM
Hello @AnkitT ,
You can user the script include and glide Ajax to achieve this requirement.
// Script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:02 AM
Hello @AnkitT ,
You can user the script include and glide Ajax to achieve this requirement.
// Script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:03 AM
If you still need any help, you can connect with me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:07 AM
Hi @AnkitT
Script Include:
- Retrieves the members of a group based on the provided sys_id.
- Returns the list of members as a JSON-encoded string.
var Get_Group_Info = Class.create();
Get_Group_Info.prototype = Object.extendsObject(AbstractAjaxProcessor, {
demoTest: function() {
var group = this.getParameter('sysparm_assignment_group');
var member = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', group);
gr.query();
while (gr.next()) {
member.push(gr.user.getDisplayValue()); // Collect group member names
}
return JSON.stringify(member); // Return as JSON string for client-side handling
},
type: 'Get_Group_Info'
});
Client Script:
- Sends the group sys_id to the Script Include.
- Receives the list of members and displays it in an alert.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('Get_Group_Info');
ga.addParam('sysparm_name', 'demoTest');
ga.addParam('sysparm_assignment_group', newValue);
ga.getXMLAnswer(function(response) {
var members = JSON.parse(response);
alert("Group Members: " + members.join(', '));
});
}
……………………………………………………………………………………………………
Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:17 AM
Hello @AnkitT , You can use the combination of the Client Script and Script Include to achieve your requirement.
If the above solution helps to resolved your issue, Please mark the solution as Accepted solution and also mark it as Helpful.
Thank You.