Reference Qualifier to filter Users with HR Profiles

Joanna7
Kilo Contributor

How should look like reference qualifier for User table reference field [sys_user] to filter only users with HR Profiles [sn_hr_core_profile]? This is for record producer in standard Service Portal, not in ESC (ESC does not exist). 

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so you want to show only those users in user reference variable who have HR profile?

for this you would require advanced ref qualifier and script include

something like this

javascript: new getRecords().getUsers();

Script Include:

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

	getUsers: function(){
		var arr = [];
		var hrRec = new GlideRecord('sn_hr_core_profile');
		hrRec.addNotNullQuery('user');
		hrRec.query();
		while(hrRec.next()){
			arr.push(hrRec.user.toString());
		}
		return 'sys_idIN' + arr.join();
	},

	type: 'getRecords'
};

Regards
Ankur

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

V_31
Tera Expert

Hi @Ankur Bawiskar , I am trying to achieve the same thing and have tried what you have suggested but this did not work. Am i doing something wrong?

 

Subject person field

find_real_file.png

Script include

find_real_file.png

Hi,

call the script include name with the complete API name and not just name

Regards
Ankur

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

Thank you Ankur that is now working as expected