- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 01:30 PM
Hi SN Community,
I have a script include that is invoked by a client script. The script include is suppose to query a table and return data to populate a list of options for a field. The issue is that when the client script is executed, the response is returning Null and I see an error message from the system log:
Exception occurred while checking rate limit: Cannot invoke "com.glide.one_extend.entity.ProviderMapping.getProviderId()" because the return value of "com.glide.one_extend.entity.GenAIConfiguration.getProviderMapping()" is null.
The client script is in a different scope than the script include. For the script include, I have accessible from selected to all application scopes and client callable checked.
I am not sure what is the cause of the issue. I am wondering if someone can provide some sort of insights? The coding to the script include and client script are below.
Client Script
function onLoad() {
//Type appropriate comment here, and begin script below
var getEnquiryType = g_form.getValue('enquiry_type');
if (getEnquiryType) {
var ga = new GlideAjax('x_csm.CsmGetLeadTeamOption');
ga.addParam('sysparm_name' , 'getOptions');
ga.addParam('enquiryType', getEnquiryType);
debugger;
ga.getXMLAnswer(function(response) {
console.log('raw response ' + response);
try {
var leadTeamOptions = JSON.parse(response);
g_form.clearOptions('lead_team');
leadTeamOptions.forEach(function(option) {
g_form.addOption('lead_team', option, option);
});
} catch (e) {
console.error('Error parsing response: ', e);
}
});
}
}
Script Include
var CsmGetLeadTeamOption = Class.create();
CsmGetLeadTeamOption.prototype = Object.extendsObject(global.AbstractAjaxProcessor,{
initialize: function() {},
getOptions: function(){
var enquiryType = this.parameter('enquiryType');
var leadTeamOptions = [];
gs.log('random log in script include');
var leadTeamGR = new GlideRecord('x_csm_cf_lead_team');
leadTeamGR.addEncodedQuery('Enquiry TypesCONTAINS',enquiryType);
leadTeamGR.query();
gs.log('DEBUG: query lead team gr '+leadTeamGR);
while(leadTeamGR.next()){
leadTeamOptions.push({
value: leadTeamGR.sys_id.toString(),
label: leadTeamGR.name.toString()
});
}
gs.log('DEBUG: lead team options '+ JSON.stringify(leadTeamOptions));
return JSON.stringify(leadTeamOptions);
},
type: 'CsmGetLeadTeamOption'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 08:24 PM
Things to correct
1) client callable script include should not have initialize() method, so remove it
2) you should use this.getParameter() and not this.paremeter()
Things to check
1) is the script include and client script in same scope
2) is the script include client callable
3) don't use gs.log() if you are scope then it will break, please use gs.info()
Updated one
Script Include:
var CsmGetLeadTeamOption = Class.create();
CsmGetLeadTeamOption.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getOptions: function() {
var enquiryType = this.getParameter('enquiryType');
var leadTeamOptions = [];
gs.info('DEBUG: Enquiry Type - ' + enquiryType);
var leadTeamGR = new GlideRecord('x_csm_cf_lead_team');
leadTeamGR.addEncodedQuery('enquiryColumnCONTAINS' + enquiryType); // give the correct column name herre
leadTeamGR.query();
while (leadTeamGR.next()) {
leadTeamOptions.push({
value: leadTeamGR.sys_id.toString(),
label: leadTeamGR.name.toString()
});
}
gs.info('DEBUG: Lead Team Options - ' + JSON.stringify(leadTeamOptions));
return JSON.stringify(leadTeamOptions);
},
type: 'CsmGetLeadTeamOption'
});
Client Script:
function onLoad() {
var getEnquiryType = g_form.getValue('enquiry_type');
if (getEnquiryType) {
var ga = new GlideAjax('x_csm.CsmGetLeadTeamOption');
ga.addParam('sysparm_name', 'getOptions');
ga.addParam('enquiryType', getEnquiryType);
ga.getXMLAnswer(function(response) {
console.log('raw response ' + response);
try {
var leadTeamOptions = JSON.parse(response);
g_form.clearOptions('lead_team');
leadTeamOptions.forEach(function(option) {
g_form.addOption('lead_team', option.value, option.label);
});
} catch (e) {
console.error('Error parsing response: ', e);
}
});
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 02:56 PM
Can you confirm, the script include is client callable?
Also if you can use gs.info instead of gs.log to see if the script is entering the function.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 08:24 PM
Things to correct
1) client callable script include should not have initialize() method, so remove it
2) you should use this.getParameter() and not this.paremeter()
Things to check
1) is the script include and client script in same scope
2) is the script include client callable
3) don't use gs.log() if you are scope then it will break, please use gs.info()
Updated one
Script Include:
var CsmGetLeadTeamOption = Class.create();
CsmGetLeadTeamOption.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getOptions: function() {
var enquiryType = this.getParameter('enquiryType');
var leadTeamOptions = [];
gs.info('DEBUG: Enquiry Type - ' + enquiryType);
var leadTeamGR = new GlideRecord('x_csm_cf_lead_team');
leadTeamGR.addEncodedQuery('enquiryColumnCONTAINS' + enquiryType); // give the correct column name herre
leadTeamGR.query();
while (leadTeamGR.next()) {
leadTeamOptions.push({
value: leadTeamGR.sys_id.toString(),
label: leadTeamGR.name.toString()
});
}
gs.info('DEBUG: Lead Team Options - ' + JSON.stringify(leadTeamOptions));
return JSON.stringify(leadTeamOptions);
},
type: 'CsmGetLeadTeamOption'
});
Client Script:
function onLoad() {
var getEnquiryType = g_form.getValue('enquiry_type');
if (getEnquiryType) {
var ga = new GlideAjax('x_csm.CsmGetLeadTeamOption');
ga.addParam('sysparm_name', 'getOptions');
ga.addParam('enquiryType', getEnquiryType);
ga.getXMLAnswer(function(response) {
console.log('raw response ' + response);
try {
var leadTeamOptions = JSON.parse(response);
g_form.clearOptions('lead_team');
leadTeamOptions.forEach(function(option) {
g_form.addOption('lead_team', option.value, option.label);
});
} catch (e) {
console.error('Error parsing response: ', e);
}
});
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2025 08:57 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 08:34 AM
Hi @Ankur Bawiskar,
I updated the changes, but I am still getting a error message "Error parsing response: TypeError: Cannot read properties of null (reading 'forEach')" from the console log when the client script executes.
Also, can you confirm if the gs.info log statements are found in System > script log statement? If so, I was not able to see any log statements from the script includes. Does this mean that the script includes never executed? Hence why the response is returning null?