how to assign the users manager to the catalog item ?

dixia1234
Kilo Contributor

Hello folks,

i really need help.can anyone clearly explain it.

I have couple of questions please take time and explain.

1.in maintain items i created the catalog item named ipod  and there are some variables like for whom it it requested for and the manager(reference to sys_user).and a temporary manager.

my problem is:

when requested_for is selected how to populate the manager..

i have tried the catalog client script: 

Applies to: variable set

Catalog item: ipod

varaible name: requested_for

onchange(oldvalue, newvalue template loading)

if(isloading||newValue=");

g_form.setvalue('manager',");

return;

 

var gr=g_form.getReference('requested_for' calldo);

function calldo(gr){

g_form.setValue('manager','gr.department_head');

}

any mistakes in the script please do check..

 

2.If the user has no manager then it should be assigned to a temporary manager.

how to achieve that ?

 

 

3.gs.getuser.getuserByID(gs.getuser.getManagerID) 

i understand this to get the manager'ID but not able to understand where to use this

An example for that code could be helpful 

 

1 ACCEPTED SOLUTION

Vinayak10
Kilo Guru

Hii 

why you not try script include? and call it using onChange client script

Script Include

 

userInfo:function(){
var cdata = this.getParameter('sysparm_user_name');   //vlaue from client script

var mngr = '' ; //Variable declaration
var gr = new GlideRecord("sys_user");   //glide with user table
gr.addQuery("sys_id", cdata);    ////find users record
gr.query();
if (gr.next()) {
mngr=gr.getValue('manager');    //get user manager
}

if(mngr == ''){

// Set your temporary manager

}

else{

return mngr;

}

 

// and call it using glideAjax from onchange client script

 

Mark Correct if you find helpful

Thanks 

Vinayak

 

View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

Please correct the script to

 

function onChange(control, oldValue, newValue, isLoading) {
var gr=g_form.getReference('requested_for', calldo);
}
function calldo(gr){

g_form.setValue('manager',gr.manager);

}

 

 Also whom do you want to be the temporary manager?

 


Please mark this response as correct or helpful if it assisted you with your question.

hello tq for your response.

i need to set the department head as the manager of my catalog item.

i want to set the temporary manager should be of the group member named ServiceDesk.

Do you have a department head field in user table. I think it will be in department table. 

You will need a script include, so that you can do all kind of check and assign the appropriate manager.

 

I will try to provide solution to you by tomorrow, if you dont have anything till tomorrow


Please mark this response as correct or helpful if it assisted you with your question.

Vinayak10
Kilo Guru

Hii 

why you not try script include? and call it using onChange client script

Script Include

 

userInfo:function(){
var cdata = this.getParameter('sysparm_user_name');   //vlaue from client script

var mngr = '' ; //Variable declaration
var gr = new GlideRecord("sys_user");   //glide with user table
gr.addQuery("sys_id", cdata);    ////find users record
gr.query();
if (gr.next()) {
mngr=gr.getValue('manager');    //get user manager
}

if(mngr == ''){

// Set your temporary manager

}

else{

return mngr;

}

 

// and call it using glideAjax from onchange client script

 

Mark Correct if you find helpful

Thanks 

Vinayak