I want to show the group member in alert

AnkitT
Tera Contributor

Hello Community,

 

I want to show the group member in alert, can anyone tell me how to acheive this.

2 ACCEPTED SOLUTIONS

Abhishek_Thakur
Mega Sage

Hello @AnkitT ,

You can user the script include and glide Ajax to achieve this requirement.

 

// Script include

var Get_Group_Info = Class.create();
Get_Group_Info.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    demoTest:function(){
    var group = this.getParameter('sysparm_assignment_group');
    var GR = new GlideRecord("sys_user_group");
    GR.addQuery('sys_id',group);
    GR.query();
    if(GR.next()){
        var member = [];
        var mem1 = new GlideRecord("sys_user_grmember");
        mem1.addQuery('group',GR.getUniqueValue());
        mem1.query();
        while(mem1.next()){
            member.push(mem1.user.getDisplayValue().toString()); //This will return the members of that group
        }
        return member.toString();
    }
    },

    type: 'Get_Group_Info'
});
 
// Client script
 
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(callback);
   function callback(response){
    var r = JSON.stringify(response);
    alert(r);
   }

 

View solution in original post

Abhishek_Thakur
Mega Sage

If you still need any help, you can connect with me.

View solution in original post

5 REPLIES 5

Satishkumar B
Giga Sage
Giga Sage

Hi @AnkitT and @Abhishek_Thakur ,

I’ve noticed a pattern where @AnkitT  questions are frequently answered by @Abhishek_Thakur , and the solutions are quickly marked as helpful or correct. While I appreciate the prompt support, I’d like to encourage everyone to use the community platform to share knowledge and foster learning and not to breach the conduct. Let’s all aim to engage in discussions that help us grow and benefit the entire community. Thank you for your understanding and cooperation!

SatishkumarB_0-1721636776542.png

#Servicenow #ServicenowCommunity 
@Sarah G_ @Servicenow