Client script calling script include scope mismatch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 10:30 AM
I have created a scoped application that I am allowing most access to. I have a catalog client script which is trying to call a script include and I am getting a Script: x_unoci_rapid_retu.RRCall not found in scope: x_unoci_rapid_retu, and HTTP Processor class not found: x_unoci_rapid_retu.RRCall: no thrown error.
The client script looks like this
var ga = new GlideAjax('RRCall');
it is in an scoped application but the global checkbox is checked.
The script include:
var RRcourseinfo = Class.create();
RRcourseinfo.prototype = Object.extendsObject(AbstractAjaxProcessor,{
RRCall: function() {
The script include is also in the same scoped application but is accessible from all application scopes.
I have tried putting global.RRCall and the scope of the application x_unoci_rapid_retu in the client script but to no avail, and I have also tried putting global in the 2nd line of the script include here RRcourseinfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor,{
I continue to get the same error each time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 10:55 AM
Hi,
You should only have to update line #2 of the script include as you indicate you have done:
RRcourseinfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor,{
Then in your client script (in the same scope) you can simply call the script/function (looks like you were trying to call the function directly instead of identifying the script include then function using the sysparm_name parameter):
var ga = new GlideAjax('RRcourseinfo');
ga.addParam('sysparm_name', 'RRCall');
Hope this helps.
--David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 11:13 AM
Hi David,
I have updated the script include to be this.
RRcourseinfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor,{
and the client script to
var ga = new GlideAjax('RRcourseinfo');
but oddly enough I am still getting the same error. Again, the script include is accessible from all scopes, and the client script has global checked, this is very confusing. I have read on the site that I might need to
- address your script include with the scope name prefix. E.g. javascript:new myscope.myScriptInclude().myFunction(
I am unsure of what that is asking or why it would need to be done.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 11:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 12:58 PM
Sure can,
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') { return; }
console.log("GlideAjax:x_unoci_rapid_retu.Rapid Return Course Call beginning"); // log beginning of function
var ga = new GlideAjax('RRcourseinfo');
ga.addParam('sysparm_name', 'RRCall');
ga.addParam('sysparm_x_unoci_rapid_retu_course_code', "");
console.log("GlideAjax: Rapid Return Course Call, finished addParam");
//alert("hello");
ga.getXML(RRCallParse);
console.log("GlideAjax: Rapid Return Course Call, getXML call finished");
//alert(response);
function RRCallParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var obj = JSON.parse(answer);
console.log("GlideAjax: Rapid Return Course Call -> RRCallParse, answer is: " + response);
for (var i=0;i<obj.length;i++){
g_form.setValue(x_unoci_rapid_retu_quarter,obj.quarterName);
g_form.setValue(x_unoci_rapid_retu_course_name,obj.name);
g_form.setValue(x_unoci_rapid_retu_total_students,obj.numStudents);
g_form.setValue(x_unoci_rapid_retu_quartershortcut,obj.qtr);
}
}
console.log("GlideAjax: x_unoci_rapid_retu.Rapid Return Course Call finished");
}
The script include is here
var RRcourseinfo = Class.create();
RRcourseinfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor,{
RRCall: function() {
var input = this.getParameter('sysparm_x_unoci_rapid_retu_course_code');
var responseBody;
var requestBody;
var r;
var httpstatus;
try {
r = new sn_ws.RESTMessageV2('x_unoci_rapid_retu.EEE course information ', 'Default GET');
r.setStringParameterNoEscape('Course Code', input);
console.log("firing api call");
var response = r.execute();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.message;
}finally {
requestBody = r ? r.getRequestBody():null;
}
{
var obj = {};
var parsedResponse = JSON.parse(responseBody);
obj.quarter = x_unoci_rapid_retu_quarter;
obj.quarterName = parsedResponse.qtrName;
obj.courseName = x_unoci_rapid_retu_course_name;
obj.name = parsedResponse.name;
obj.totalStudents = x_unoci_rapid_retu_total_students;
obj.numStudents = parsedResponse.numStudents;
obj.quarterShortcut = x_unoci_rapid_retu_quartershortcut;
obj.qtr = parsedResponse.qtr;
var objString = JSON.stringify(obj);
return objString;
}
},
type: 'Rapid Return Course Call'
});