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

vinothkumar
Tera Guru

1) Right click on assigned to field > configure dictionary.

2) Update dependent as Assignment group as shown. It will work

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

correct you need to create script include function and call that in the reference qualifier field of the second variable

Did you try to create and proceed?

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

I did and it has syntax errors.  Here is one of my attempts:

function refqualassignedto(){
var group = current.variables.assignment_group; // your assignment group variable name
var user_array = [];

if(group!=''){
var getMembers = new GlideRecord('sys_user_grmember');
getMembers.addQuery('group',group);
getMembers.query();

while(getMembers.next())
{
user_array.push(getMembers.getValue('user'));
}
return 'sys_idIN' + user_array.toString();
}
else{
return 'active=true';
}
}

Hi,

can you share the complete script include code; the above function looks good with only 1 change required; pass the group sys id from the ref qualifier to this function

function refqualassignedto(assignmentGroup){
var group = assignmentGroup; // your assignment group variable name
var user_array = [];

if(group!=''){
var getMembers = new GlideRecord('sys_user_grmember');
getMembers.addQuery('group',group);
getMembers.query();

while(getMembers.next())
{
user_array.push(getMembers.getValue('user'));
}
return 'sys_idIN' + user_array.toString();
}
else{
return 'active=true';
}
}

Can you share the script from where this is getting called i.e. reference qualifier of the second variable?

That would help to debug more

Regards

Ankur

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