- 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-28-2025 09:10 AM
yes if script include never executed it will give null in client side
you need to debug step by step
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 09:28 AM
Hi @DominicL ,
try this out
SI
update the encQuery variable value if needed with actual encoded query (better build it using the condition builder)
make sure the client callable is checked and accessible from to all application scopes if the client script is in different scope
var CsmGetLeadTeamOption = Class.create();
CsmGetLeadTeamOption.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getOptions: function() {
var leadTeamOptions = [];
try {
var enquiryType = this.getParameter('enquiryType');
gs.info('random log in script include');
var encQuery = 'enquiry_typeLIKE' /*make changes to this if needed*/ + enquiryType;
var leadTeamGR = new GlideRecord('x_csm_cf_lead_team');
leadTeamGR.addEncodedQuery(encQuery);
leadTeamGR.query();
gs.info('DEBUG: query lead team gr ' + leadTeamGR);
while (leadTeamGR.next()) {
leadTeamOptions.push({
value: leadTeamGR.getValue('sys_id'),
label: leadTeamGR.getValue('name')
});
}
} catch (err) {
gs.error('Error: ' + err);
}
gs.info('DEBUG: lead team options ' + JSON.stringify(leadTeamOptions));
return JSON.stringify(leadTeamOptions);
},
type: 'CsmGetLeadTeamOption'
});
Client Script
added few more logs to check where it's going wrong
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);
ga.getXMLAnswer(function(response) {
console.log('raw response ' + response);
try {
if (response) {
var leadTeamOptions = JSON.parse(response);
if (leadTeamOptions && leadTeamOptions.length) {
g_form.clearOptions('lead_team');
leadTeamOptions.forEach(function(option) {
g_form.addOption('lead_team', option.value, option.label);
});
}else{
console.log('no options');
}
} else {
console.log('no response')
}
} catch (e) {
console.error('Error parsing response: ', e);
}
});
}
}
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
05-15-2025 11:35 AM
Hi, I am new to SN. I am tying to build a simple ATF testcase to impersonate a user and open up a case/form, just two steps. But it failed on the second step with the same error message (see screenshot below). No idea how to fix it. It is blocking our work. Your help is appreciated!