- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2020 04:50 AM
I tried populating location field using g_form.getReference() it worked. but I am not able to achieve it using GlideAjax. Kindly help.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2020 06:08 AM
Did this work for you? Still any questions? Could you please update. I do see you are posting other questions again. So please resond to the topics your posting and where people are responding to.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2020 11:38 AM
Did you check the article I mentioned? Contains detailed explanation and examples.
Concerning getXMLAnswer vs getXML: retrieving only the answer versus retrieving the whole documents, so performance.
Client Side Scripting: Go for GlideAjax (with getXMLAnswer)!
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2020 05:45 PM
Hi,
getXMLAnswer() saves you a line of code every time you use it. There shouldn't be any noticeable difference in speed, though this method is probably guaranteed to be slightly slower as it runs at least one more line of code each time. So ease of use vs minuscule difference in speed.
with getXMLAnswer() you no longer need this line of code each time.
var answer = response.responseXML.documentElement.getAttribute("answer");
Please Mark Correct/Helpful answer if it help you in any way.
Thanks and Regards,
Kunal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2020 10:26 PM
Hi there,
To understand more about getXMLAnswer vs getXML, read below article:
getXMLAnswer vs getXML
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2020 06:21 AM
Hi, Please find the below code that I have written but still no luck, location field is showing blank.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga=new GlideAjax('AutopopulatedetailsC');
ga.addParam('sysparm_name',setEmail);
ga.addParam('sysparm_loc',g_form.getValue('caller_id'));
ga.getXML(getResponse);
function getResponse(response)
{
//var answer=response.responseXML.documentElement.getAttribute('answer');
//return answer;
var answer=response;
g_form.setValue('location',answer);
}
//Type appropriate comment here, and begin script below
}
Script Include:
var AutopopulatedetailsC = Class.create();
AutopopulatedetailsC.prototype = Object.extendsObject(AbstractAjaxProcessor, {
setEmail:function(){
var gr=new GlideRecord('sys_user');
gr.addQuery('sys_id',this.getParameter('sysparm_loc'));
gr.query();
if(gr.next())
{
return gr.location.name.toString();
}
},
type: 'AutopopulatedetailsC'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2020 09:37 AM
Hi,
And remove var answer=response; because you are not using getXMLanswer() in client script.
So that's why value is not get.
Use this below script in client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga=new GlideAjax('AutopopulatedetailsC');
ga.addParam('sysparm_name',setEmail);
ga.addParam('sysparm_loc',g_form.getValue('caller_id'));
ga.getXML(getResponse);
function getResponse(response)
{
var answer=response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('location',answer);
}
Please Mark Correct answer if it help you in any way.
Thanks and Regards,
Kunal.