Script include for service catalog
- 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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 09:36 AM
try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert(g_form.getValue('user_name'));
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 09:40 AM
Hi,
No still issue exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 02:25 AM
Comment this for testing,
if (isLoading || newValue == '') {
return;
}
Just trying to narrow down on the issue here.
Also Add steps how you are testing this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 04:10 AM
Hi @UmeshGowda
Can you try updating client script as below :
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.getXMLAnswer(test); // **use getXMLAnswer
function test(answer){
var result = answer; // get result
alert(result);
}
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates