Need to visible only managers in reference field on incident table.

Mallika1
Giga Contributor

Hello Developers!

I am trying to get only managers in reference field on incident table.

I have tried with manager is not empty condition in reference qualifier, it shows users those have managers.

But I need to get only managers in field.

Please anyone suggest me.

Thanks in advance!

1 ACCEPTED SOLUTION

Hi,

update as this to show only the managers

var GetUsers = Class.create();
GetUsers.prototype = {
	initialize: function() {
	},

	getOnlyManagers: function(){
		var arr = [];
		var gr = new GlideRecord("sys_user");
		gr.addQuery("manager", "!=", "");
		gr.query();
		while(gr.next()) {
			arr.push(gr.getValue('sys_id'));
		}
		var arrayUtil = new ArrayUtil();
		arr = arrayUtil.unique(arr);
		return arr.toString();
	},

	type: 'GetUsers'
};

Regards
Ankur

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

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron

Hi,

you will have to use advanced reference qualifier for this

1) query entire sys_user table and get only the managers from manager field and return those users

Script Include:

var GetUsers = Class.create();
GetUsers.prototype = {
	initialize: function() {
	},

	getOnlyManagers: function(){
		var arr = [];
		var gr = new GlideRecord("sys_user");
		gr.addQuery("manager", "!=", "");
		gr.query();
		while(gr.next()) {
			arr.push(gr.getValue('sys_id'));
		}
		return arr.toString();
	},

	type: 'GetUsers'
};

Advanced ref qualifier:

javascript: 'sys_idIN' + new GetUsers().getOnlyManagers();

Regards
Ankur

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

chandan15
Tera Contributor
the script is taking time to execute. Performance is going down