- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 12:54 AM
I have variable name, User(user_id) and Line Manager(line_manager). Line manager should populated based on the user selected. Please suggest the catalog client script for this.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 02:17 AM
I would suggest use script include,
Use below code
Script include
var userDetails = Class.create();
userDetails .prototype = Object.extendsObject(AbstractAjaxProcessor, {
getManager: function() {
var gr=new GlideRecord("sys_user");
gr.addQuery("sys_id",this.getParameter('sysparam_id'));
gr.query();
gr.next();
if(gr.manager!=''){
return gr.manager.name;
}
else
{
return "blank";
}
},
type: 'userDetails '
});
Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('userDetails');
ga.addParam('sysparm_name','getManager'); // pass script include function
ga.addParam('sysparam_id',newValue);
ga.getXML(Process);
}
function Process(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue("man",answer); // man should be line manager variable name
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 02:25 AM
Hi Venkatesh,
I would like to echo the same thing as harishkumar responded. Please find his response below. It is always recommended to do database query from server side scripting. Hence, please use a Script Include and call that in your Catalog Client Script.
I hope this helps.Please mark correct/helpful based on impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 02:17 AM
I would suggest use script include,
Use below code
Script include
var userDetails = Class.create();
userDetails .prototype = Object.extendsObject(AbstractAjaxProcessor, {
getManager: function() {
var gr=new GlideRecord("sys_user");
gr.addQuery("sys_id",this.getParameter('sysparam_id'));
gr.query();
gr.next();
if(gr.manager!=''){
return gr.manager.name;
}
else
{
return "blank";
}
},
type: 'userDetails '
});
Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('userDetails');
ga.addParam('sysparm_name','getManager'); // pass script include function
ga.addParam('sysparam_id',newValue);
ga.getXML(Process);
}
function Process(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue("man",answer); // man should be line manager variable name
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 08:46 AM
Thanks HarishKumar, It is working. it the correct answer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 09:28 PM
If it is working as expected can you mark the answer as correct?
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2024 10:25 PM
Hello @Harish KM ,
Can you tell me where I missed.
Catalog client script: