- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2025 02:21 AM
I’m trying to use GlideAjax to fetch the Caller’s email from the sys_user table and display it when I select a Caller on the form.
I’ve written both the Client Script and Script Include, and the script runs without errors, but the output is not reflecting on the form (alert not showing any value). If anyone knows what's the issue, please help me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2025 09:38 AM - edited 10-17-2025 09:40 AM
Hi @sirijonna82 ,
It looks like your Script Include and Client Script have a few small syntax and naming issues, that’s why your GlideAjax call isn’t returning anything.
Here's a complete working code:
Script Include:
var getEmailId = Class.create();
getEmailId.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getEmailId: function() {
var callerId = this.getParameter('sysparm_value'); // caller sys_id
var user = new GlideRecord('sys_user');
if (user.get(callerId)) {
return user.getValue('email'); // always use getValue for consistency
}
return ''; // fallback
},
type: 'getEmailId'
});
Client-script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('getEmailId');
ga.addParam('sysparm_name', 'getEmailId');
ga.addParam('sysparm_value', g_form.getValue('caller_id'));
ga.getXMLAnswer(function(answer) {
g_form.setValue('u_email', answer);
});
}
The Output:
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2025 09:38 AM - edited 10-17-2025 09:40 AM
Hi @sirijonna82 ,
It looks like your Script Include and Client Script have a few small syntax and naming issues, that’s why your GlideAjax call isn’t returning anything.
Here's a complete working code:
Script Include:
var getEmailId = Class.create();
getEmailId.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getEmailId: function() {
var callerId = this.getParameter('sysparm_value'); // caller sys_id
var user = new GlideRecord('sys_user');
if (user.get(callerId)) {
return user.getValue('email'); // always use getValue for consistency
}
return ''; // fallback
},
type: 'getEmailId'
});
Client-script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('getEmailId');
ga.addParam('sysparm_name', 'getEmailId');
ga.addParam('sysparm_value', g_form.getValue('caller_id'));
ga.getXMLAnswer(function(answer) {
g_form.setValue('u_email', answer);
});
}
The Output:
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
