Script includes retrieving department head

Teteziho
Tera Contributor

Im trying to retrieve with an reference qualifier and my client script the department head of the department selected in my configuration item and fill it in manager field in my CI but It doest work : 

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

retrieveDepartmentHead: function(department){
var grDept = new GlideRecord('cmn_department');
grDept.addQuery('sys_id',department);
grDept.query();
if(grDept.next()){
var deptHead = grDept.dept_head;

return deptHead;
}

},
type: 'EmboardingLibrary'

};
 
reference qualifier field manager : javascript:new EmboardingLibrary.retrieveDepartmentHead(current.variables.department);
5 REPLIES 5

would it be best practice to make an client script and how would I structure it as code ? thank already for your help