Automatically populate member_list with all users from selected group?

MBarrott
Mega Sage

Our users dislike the fact that once they choose a group, they have to select the applicable users one by one rather than a mass selection. 

 

Is there a way to automatically populate the member_list field with ALL users from the chosen group, and they can then filter out?

 

MBarrott_0-1724944662254.png

 

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

Hi @MBarrott ,

 

Here you go:

HemanthM1_0-1724947518410.png

 

HemanthM1_1-1724947538727.png

Output:😍

HemanthM1_2-1724947581872.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var member = new GlideAjax("getMembers");
    member.addParam("sysparm_name", "userList")
    member.addParam("groupid", newValue);
    member.getXMLAnswer(output)

    function output(result) {
        g_form.setValue("u_member_list", result);
    }


    //Type appropriate comment here, and begin script below

}
var getMembers = Class.create();
getMembers.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	userList: function(){
		var members="";
		var id = this.getParameter("groupid");
		var grpMembers = new GlideRecord("sys_user_grmember")
		grpMembers.addQuery("group", id);
		grpMembers.query();
		while(grpMembers.next()){
			members+=","+grpMembers.user.toString();
		}
		return members;
	},

    type: 'getMembers'
});

 

Hope this helps!!!

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

5 REPLIES 5

Hi @Bert_c1 ,

 

Thats correct.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025