Unhandled exception in GlideAjax. Cannot read properties of null (reading 'length') in stage Env1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 02:09 AM
There is on change Catalog client script which will trigger when the request type field is changed. This client script will internally call script include.
While performing on change action ESC form I'm getting console error called (Only in STAGE environment)"Unhandled exception in GlideAjax. Cannot read properties of null (reading 'length')".
below this the client script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 02:16 AM
You may not have required data in Stage env. Basically your "subRequests_list" object in script include is empty which throws this error when you try to find its length in client script.
Regards,
Abhijit
ServiceNow MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 02:18 AM
@Kiran Maruthi Please update the onChange Client script as follows and see if the error disappears.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
g_form.clearOptions("sub_request_e_c");
var gaServiceGrpsAjax = new GlideAjax("SI Name");
gaServiceGrpsAjax.addParam('sysparm_name', 'getSubRequest');
gaServiceGrpsAjax.addParam('sysparm_requestType', newValue);
gaServiceGrpsAjax.getXMLAnswer(function(answer) {
var response = JSON.parse(answer);
if(response){
g_form.addOption('sub_request_e_c', '', '-- None --');
for (var i = 0; i < response.length; i++) {
g_form.addOption('sub_request_e_c', response[i], response[i]);
}
}
g_form.setValue('sub_request_e_c','');
});
//Type appropriate comment here, and begin script below
}