What's wrong with my GlideAjax?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 01:32 AM
I wrote a simple glide ajax to get caller's email address and add it to the short description.
Apparently, the script include part is not invoked and I am not able to see logs. Please identify the issue.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 01:51 AM
Hi @RFJ1
Please try provided scripts in your script include and client script:
Script include
var CallerInfo = Class.create();
CallerInfo.prototype = {
initialize: function() {},
getCallerEmail: function(callerId) {
var user = new GlideRecord('sys_user');
if (user.get(callerId)) {
return user.email;
}
return '';
},
type: 'CallerInfo'
};
OnChange client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var callerId = g_form.getValue('caller_id');
if (callerId) {
var callerEmail = '';
var ga = new GlideAjax('CallerInfo');
ga.addParam('sys_id', callerId);
ga.getXMLAnswer(function(response) {
callerEmail = response.responseXML.documentElement.getAttribute("answer");
if (callerEmail) {
var shortDescription = g_form.getValue('short_description');
g_form.setValue('short_description', shortDescription + ' - ' + callerEmail);
}
});
}
}
I hope my answer helps you to resolve your issue, if yes mark my answer helpful & correct.
THANK YOU
rajesh chopade.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 01:58 AM
gr.get() retrieves the user record.
So you shouldnt use if(gr.next()) - just gr.get() and then pick the email to return
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 02:22 AM
Hi @RFJ1 ,
Can I know which log is not visible?
Is it first one 'entering script include' or both first and last?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 03:09 AM
Both