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 03:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 03:28 PM
Ok thank you for sharing that. I see the error. The Script Include should be named "RRcourseinfo" not "Rapid Return Course Call" just as defined on line #1 in the class definition. Also line #2 needs to have AbstractAjaxProcessor identified in the global scope as so:
global.AbstractAjaxProcessor
Once you update the name of the script include the following block of code in your client script will be able to properly call the script:
var ga = new GlideAjax('RRcourseinfo');
ga.addParam('sysparm_name', 'RRCall');
ga.addParam('sysparm_x_unoci_rapid_retu_course_code', "");
ga.getXML(RRCallParse);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 03:42 PM
A step forward! I am getting a different error, but at least it isn't claiming it can't access it anymore. The error I am getting is pointing to the g_form.setValue operations I have, I'm guessing that it's not defined because something is going wrong with the script include. Looking at the http log it appears that the course code I am trying to pass from the client script to the api didn't go through, while not the best outcome I am very happy to be past that roadblock. Previously we removed the object definitions, is there a better way to do them than the way I was attempting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 03:53 PM
Nice baby steps! 🙂
For the setValue error are these actual field names on the form where this client script is running?
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);
If so then its most likely has to do with the obj being returned to the script as empty like you said.
Using the expected JSON response:
{"status":"VALIDCCODE","qtr":"F18","qtrName":"Fall Qtr 2018","name":"TEST 99000 LEC A: E3 TOOLS (99000)","shortName":"TEST 99000 LEC A (99000)","deptName":"Test","numStudents":1}
The proper way to get this back to the client script is simply return the requestBody variable back to the client script the run JSON.parse(answer) as you were previously doing. You can then access the objects using:
obj.status
obj.qtr
obj.qtrName
etc
Use the parameter names as defined in the returned JSON body. If the REST message is not returning a response as expected you should enable outbound REST logging then check the logs to see what is causing the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2019 08:59 AM
Hi David,
I am indeed trying to set the value of those 4 fields, I have noticed that the script include is NOT getting the course code that I've entered to trigger the client script. Have I made a mistake in trying to pass ga.addParam('sysparm_x_unoci_rapid_retu_course_code', ""); ?
It's either that, or the definition that I have in my script include is the issue. I tried to define it as input. Looking at my rest message itself I am inserting this into the URL ${input} which I thought would work.
