Unhandled exception in GlideAjax. Cannot read properties of null (reading 'responseXML')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 09:22 AM
Hello,
I am getting the error message above when I try to execute a script.
It is Client callable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 10:53 AM
Hello @StuPayne,
I want to highlight a few things when we work with client-server side calls. We usually have to pack the data when we send it to client side, for that is recommended to use "return new JSON().encode(instanceName_s);", this is for our case and when you load it to client side you need to unpack it from that "JSON" datatype, for this you can use "response.responseXML.documentElement.getAttribute("answer").evalJSON()".
var GetInstanceInfo = Class.create();
GetInstanceInfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
initialize: function() {},
getInstanceName: function() {
var instanceName_s = gs.getProperty('instance_name');
gs.info('Instance Name: ' + instanceName_s);
return instanceName_s;
},
getInstanceURL: function() {
var instanceURL_s = gs.getProperty('glide.servlet.uri');
gs.info('Instance URL: ' + instanceURL_s);
return new JSON().encode(instanceURL_s);
},
type: 'GetInstanceInfo',
isPublic: true
});
function onLoad() {
// Create my GetInstance Class
var ga = new GlideAjax('GetInstanceInfo');
ga.addParam('sysparm_name', 'getInstanceURL');
ga.getXMLAnswer(function(response) {
g_form.setValue('current_instance', response.responseXML.documentElement.getAttribute("answer").evalJSON());
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 11:08 AM
Both of these solutions worked kind of. The value is being shown on the sreen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 03:02 PM
@StuPayne
Is the issue resolved?
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 11:48 AM
I've tried everything suggested but not luck. My manager told me that he has this same issue, and for me to move on.
Thank you all for your help.