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

Hi,

So what is required?

The script will return only those users which are managers. Is that not required?

Are you saying when user does the lookup you need to show additional field (manager) along with Name, First Name, Last Name, Email?

Regards
Ankur

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

Need to get only managers.

Hi,

then the advanced ref qualifier I gave should give you only those users who are manager of somebody

Regards
Ankur

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

Hi,

It shows only managers but it show duplcates also, that means it show double times if the manager has two users.

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