Script include for service catalog
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 09:26 AM
Hello Team,
Am trying to auto populate user location in service catalog using script include method and client script, when ever am selecting username.
Below is the client script i have written:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('LocationDetails');
ga.addParam('sysparm_name','getLocation');
ga.addParam('sysparm_value',g_form.getValue('user_name'));
ga.getXML(test);
function test(res){
var answer = res.response.documnetElement.getAttribute("answer");
alert(answer);
}
}
Below is the script include i have written :
var LocationDetails = Class.create();
LocationDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getLocation: function(){
var loc = this.getParameter('sysparm_value');
var x =new GlideRecord('sys_user');
x.addQuery('sys_id', loc);
x.query();
if(x.next()){
gs.log('location is ',+x.location);
return x.location;
}
},
type: 'LocationDetails'
});
But unfortunately, when am selecting username it's not auto populating user location filed, can someone please suggest me.