Catalog item variable: how to select User from member of the Group?

blairf
Giga Expert

It seems this question is asked over and over again, yet I'm not able to get a published solution to work.  We're on Kingston.  My catalog item has variables:

assignment_group

assigned_to

After selecting the assignment_group, the assigned_to should show only members of the group.  Can someone provide detailed steps for a new ServiceNow admin?  I suspect I need to:

1. create a Catalog Client Script on the catalog item

2. create a Reference Qualifier on the variable assigned_to

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi, 

In the assigned_to variable use advanced reference qualifier, like this:

find_real_file.png

Then create the script include:

find_real_file.png

function refqualassignedto(){


   var group = current.variables.group; // your assignment_group variable name
   var users = '';
   if(group!=''){
	   var getMembers = new GlideRecord('sys_user_grmember');
	   getMembers.addQuery('group',group);
	   getMembers.query();
	   while(getMembers.next())
	   {
		   users = users + ','+ getMembers.user;
		}
	   return 'sys_idIN' + users;
   }
   else{
	   return 'active=true';
   }
}

Please mark as correct if this helps!

Thanks

DR

View solution in original post

9 REPLIES 9

The variable assigned_to has reference qualifier:

javascript:new refqualassignedto().getMembers(current.variables.assignment_group);

 

Hi,

The reference qualifier looks good; i.e. way it is being called

Did you check by adding log statement whether that user_array is empty or not

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hi, 

In the assigned_to variable use advanced reference qualifier, like this:

find_real_file.png

Then create the script include:

find_real_file.png

function refqualassignedto(){


   var group = current.variables.group; // your assignment_group variable name
   var users = '';
   if(group!=''){
	   var getMembers = new GlideRecord('sys_user_grmember');
	   getMembers.addQuery('group',group);
	   getMembers.query();
	   while(getMembers.next())
	   {
		   users = users + ','+ getMembers.user;
		}
	   return 'sys_idIN' + users;
   }
   else{
	   return 'active=true';
   }
}

Please mark as correct if this helps!

Thanks

DR

Thank you!  This worked perfectly on the first attempt.

Thanks for this simple solution 🙂