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:01 AM
Hi @StuPayne ,
Can you replace your code and try. I hope you have a field with the name "current_instance" in the table where you are writing On Load Client Script.
If it doesn't then see what value you are getting in gs.info('Instance URL: ' + instanceURL_s); as part of troubleshooting.
ga.getXMLAnswer(prop_result);
function prop_result(response)
{
g_form.setValue("current_instance",response);
}
If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 09:15 PM
Hi @StuPayne
Can you please mark the response as helpful and accept the solution. If applicable.
By this it will help other readers as well.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 10:09 AM
Hi @StuPayne ,
update your client script
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);
});
}
getXMLAnswer parses the answer and shares it. we don't have to write this with getXMLAnswer
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 10:14 AM
Hi @StuPayne
Please use below onLoad script:
function onLoad() {
var ga = new GlideAjax('GetInstanceInfo');
ga.addParam('sysparm_name', "getInstanceURL");
ga.getXML(processResponse);
}
function processResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
g_form.setValue('current_instance', answer);
}
}
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.