The CreatorCon Call for Content is officially open! Get started here.

when i select group then only particular group members visible in left side box.

poornima srivas
Kilo Contributor

when i select group then only particular group members visible in list collector.i have achieve this but group members are visible in right side box(selected). but i want only particular group members  display in left side block.

find_real_file.pngfind_real_file.png

1 ACCEPTED SOLUTION

Hello poornima,

But the idea of the field is exactly the oposite.
The right box represent the "selected" users and the left the "users to select".

If you want to select a group and have all members selected, then you need to:

- Create a client script onChange of the group field
- In that client script, perform an ajax call to retrieve the members of the group (I think your script is doing this)
- set the field with the members with the value that is being returned from your ajax call.

This way you will set that field to be the set of members of the group. In that way you will see all members on the right side when selecting the group.

I'm not entirely sure about the output of your script: maybe it should only return a comma-separated list of user sys_ids. You need to try it out.

Let me know if this solution had any positive outcome.

Hope this helps!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

 

View solution in original post

11 REPLIES 11

Hi @poornima srivas ,

I'm trying to achieve exactly what you managed to, but for some reason it's not working. Can you spot any errors?

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
	var ga = new GlideAjax('getGroupName');
	add.Parm('sysparam_name','getGroupMembers');
	add.Parm('sysparm_gid','newValue');
	ga.getXML(callback);
	
	function callback(response)
	{
		var answer = response.resonseXML.documebntElement.getAttribute("answer");
		//var memArray=anwer.split('|');
		//var memNames = memArray[0];
		//var memValue = memArray[1];
		alert(answer);
		g_form.setValue("members_text",answer);
	}
   //Type appropriate comment here, and begin script below
}

 

var getGroupName = Class.create();
getGroupName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getGroupMembers: function() {
		var grpID = this.getParameter('sysparm_gid');
		var memObj = new GlideRecord('sys_user_grmember');
		memObj.addQuery('group', grpID);
		memObj.query();
		var nArray = [];
		var vArray = [];
		while (memObj.next()) {
			nArray.push(memObj.user.getDisplayValue().toString());
			vArray.push(memObj.getValue("user").toString());
		}
		var retValue = nArray.toString() + '|' + vArray.toString();
		return retValue;
	},
	type: 'getGroupName'
});

 

your query should be something like this (Try this in background thou)

var gr = new GlideRecord("sys_user_grmember");
gr.addEncodedQuery('group=c38f00f4530360100999ddeeff7b1298^');//replace sys_id with your group sys_id
gr.query();
gs.print(gr.getRowCount()+"-----totall members in group");
while (gr.next()){
gs.print(gr.user.name)
}