Need Help in the Reference Qualifier in Dictionary override

chalanbl
Kilo Expert

Hello Experts,

I need help in reference qualifier..!!

Basically i should filter the assigned_to field by 2 conditions.

1) assigned_to choices should be the member of the group 

2) assigned_to should have a role "DP Fracas"

I am trying something like this basically in ref qual but not working

need to satisfy both the conditions.

Note: When you clear out the assignment group then assigned to should have no choices

 

find_real_file.png

  

 

Regards,

Chalan

 

 

1 ACCEPTED SOLUTION

AirSquire
Tera Guru

Hi try the below client-callable script include and reference qualifier.

Note: you can access current object in script include

var GetUserFromAssignmentGroup = Class.create();
GetUserFromAssignmentGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	getUsers: function(){
		var sid='';
		var gr = new GlideRecord("sys_user_grmember");
		gr.addQuery("group", current.assignment_group);
		gr.query();
		while (gr.next()) {
			var ur = new GlideRecord("sys_user_has_role");
			ur.addQuery("user", gr.user);
			ur.addQuery('role','sys_id_of_your_role');
			ur.query();
			if (ur.next()) {
				sid += ur.user+',';
			}
		}
		return 'sys_idIN'+sid;
	},
    type: 'GetUserFromAssignmentGroup'
});
javascript: new GetUserFromAssignmentGroup().getUsers();

 

P.S.: Kindly mark correct if this resolved your issue. It will help future seekers in getting correctly working answers.

 

Regards

AirSquire

View solution in original post

3 REPLIES 3

Michael Fry1
Kilo Patron

Dependent is already set on the base dictionary for assigned_to - according to your screen shot.

That means you just want to Override the reference qualifier and add roles=x

where x is the role name. The role name cannot have a space in it and should be all lower case.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Chalan,

you are trying to call some method. where it is written? Is it inside any script include.

Why are you forming the query string in reference qualifier instead form it in script include and query and then return sys ids array.

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

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

AirSquire
Tera Guru

Hi try the below client-callable script include and reference qualifier.

Note: you can access current object in script include

var GetUserFromAssignmentGroup = Class.create();
GetUserFromAssignmentGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	getUsers: function(){
		var sid='';
		var gr = new GlideRecord("sys_user_grmember");
		gr.addQuery("group", current.assignment_group);
		gr.query();
		while (gr.next()) {
			var ur = new GlideRecord("sys_user_has_role");
			ur.addQuery("user", gr.user);
			ur.addQuery('role','sys_id_of_your_role');
			ur.query();
			if (ur.next()) {
				sid += ur.user+',';
			}
		}
		return 'sys_idIN'+sid;
	},
    type: 'GetUserFromAssignmentGroup'
});
javascript: new GetUserFromAssignmentGroup().getUsers();

 

P.S.: Kindly mark correct if this resolved your issue. It will help future seekers in getting correctly working answers.

 

Regards

AirSquire