Reference Qualifier to populate a field with two different fields on Change form

Lavanya Nagendr
Giga Guru

Hi All,

 

We have a requirement where we need to populate a reference field with values from two different reference fields on the form.

 

Say a reference field "Implementation Group" which currently have dependent field as "Assignment group" on the form. So when a user pick the field it will show the group members from the group on the Assignment group field. \

But now we need to make the "Implementation Group" field to show the members from both "Assignment group" field and an another "Owner group" field. so that when a user picks Implementation field it will show both the assignment group and the owner group members.

 

Note: I tried adding the "Owner group" in the Dependent field of that implementation group field but couldn't achieve the result. Can we achieve it through reference qualifier? If so kindly provide your solution for this.

1 ACCEPTED SOLUTION

Rahul Talreja
Mega Sage
Mega Sage

Hi @Lavanya Nagendr ,
Use script include as

 

//Script Include

var GroupMembers = Class.create();

GroupMembers.prototype = {

initialize: function() {
},

getGroupMembers: function(group1, group2) {
	var grp1 = new GlideRecord('sys_user_grmember');
	grp1.addQuery('group', group1);
	grp1.query();
	
	var grp2 = new GlideRecord('sys_user_grmember');
	grp2.addQuery('group', group2);
	grp2.query();
	
	var grpMembers = [];
	while (grp1.next()) {
		grpMembers.push(grp1.user.sys_id);
	}
	
	while (grp2.next()) {
		grpMembers.push(grp2.user.sys_id);
	}
	
	return 'sys_idIN'+ grpMembers.toString();
},

type: 'GroupMembers'

};

 


and call this from advance reference 

 

javascript : new GroupMembers().getGroupMembers(current.variables.group1, currenet.variables.group2;

 

Note: Please adjust the variable names of group1 and group2 as per your environment

 

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

View solution in original post

7 REPLIES 7

@Lavanya Nagendr 

Unless you share the complete script we cannot help.

The answer marked as correct might confuse future members as you mentioned the field u_implementation_group refers to group table but the answer talks about returning users which won't work.

Our aim is to help and guide you in right direction so that you can enhance the logic on top of it as we are not completely aware what's your exact requirement and what's your configuration in the instance.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Rahul Talreja
Mega Sage
Mega Sage

Hi @Lavanya Nagendr ,
Use script include as

 

//Script Include

var GroupMembers = Class.create();

GroupMembers.prototype = {

initialize: function() {
},

getGroupMembers: function(group1, group2) {
	var grp1 = new GlideRecord('sys_user_grmember');
	grp1.addQuery('group', group1);
	grp1.query();
	
	var grp2 = new GlideRecord('sys_user_grmember');
	grp2.addQuery('group', group2);
	grp2.query();
	
	var grpMembers = [];
	while (grp1.next()) {
		grpMembers.push(grp1.user.sys_id);
	}
	
	while (grp2.next()) {
		grpMembers.push(grp2.user.sys_id);
	}
	
	return 'sys_idIN'+ grpMembers.toString();
},

type: 'GroupMembers'

};

 


and call this from advance reference 

 

javascript : new GroupMembers().getGroupMembers(current.variables.group1, currenet.variables.group2;

 

Note: Please adjust the variable names of group1 and group2 as per your environment

 

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

Hi @Rahul Talreja ,

 

Thanks for your help, I have modified my script and qualifier per your suggestion, and it resulted with what i wanted 🙂