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

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Teteziho ,

 

Can u try calling ur script include in below manner from ur reference qualifier after javascript : paste below line

new EmboardingLibrary().retrieveDepartmentHead(current.variables.department);

 

Thanks,

Danish

it does not trigger because I need to first of all choose one of the department in my CI and after that it should take his departement head and copy it to manager field in my configuration item. but It does nothing 

javascript: new EmboardingLibrary().retrieveDepartmentHead(current.variables.department); 

Hi @Teteziho ,

 

Ok in that case can we create a on Change client script & make the above script include as client callable or create a new script include?

 

Thanks,

Danish