- 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 10:57 PM
HI,
please try code:-
SI:-
var reuestedutil = Class.create();
reuestedutil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
//type: 'reuestedutil':
myFunction: function()
{
var ab=this.getParameter('sysparm_var');
var gr=new GlideRecord("sys_user");
gr.addQuery('sys_id',ab);
gr.query();
if(gr.next())
{
var fname=gr.first_name;
var email=gr.email;
var phone=gr.mobile_phone;
var loc=gr.location.getDisplayValue();
return fname +'||'+ email +'||'+ phone +'||'+ loc;
}
}
});
SC Client Script:-
var ga =new GlideAjax("reuestedutil");
ga.addParam('sysparm_name','myFunction');
ga.addParam('sysparm_var',newValue);
ga.getXMLAnswer(getValue);
function getValue(response)
{
var ans=response;
var gh=ans.split("||");
g_form.setValue("name",gh[0]);
g_form.setValue("email",gh[1]);
g_form.setValue("phone",gh[2]);
g_form.setValue("location",gh[3]);
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy.
Thanks,

- 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
06-03-2024 11:31 PM
Hi,
use below code with onChange Client script,
function onChange(control, oldValue, newValue, isLoading) {
var getLocation=g_form.getReference('caller_id', LocationData);
}
function LocationData(getLocation) { // reference is passed into callback as first arguments
g_form.setValue("location",getLocation.location);
}