GlideAjax: Not able to access function inside script include

jivanjotkaur
ServiceNow Employee
ServiceNow Employee

I have created a custom application and i am trying to do a GlideAjax, though onSubmit client script , to access a script include within the same scope. I put a debug statement each inside the 'initialize' and 'testfunction' which i am calling in my client script. I found that on execution of the script only the debug statement inside initialize is reflecting in the System Logs. Is the 'testfunction' not getting called at all? The value in the 'answer' variable is also null after execution.

Following is my script include:

Screen Shot 2015-10-04 at 1.40.53 AM.JPG

Corresponding Client Script:

Screen Shot 2015-10-04 at 1.41.32 AM.JPG

20 REPLIES 20

michaelrodway
Tera Contributor

I too have this exact problem, I have also tried all these options


Answer returns null.



Any ideas?


find_real_file.png



find_real_file.png


Hello Michael,



I assume that the logging on line 13 of your Script Include outputs a value in your script logs, so you know that there is a record being found?


Change line 18 to use gr.getValue("status") instead of "gr.status".



Also, can you log the value of answer in your client script (before the "if (answer)" conditional on line 14)? Use "console.log(answer)" and check out what is logged out to your browser's console when this runs.



Thanks


Cory


Hi Cory,



Thanks for the quick response.



So unfortunately, I don't even get to the first log statement on Line 6 in the Script Include. I did change grabbing the value to gr.getValue



As well, I outputted to the console:


find_real_file.png



Also, I tried to remove the scope from the object creation in the client script, with the same result:


ie. FROM: var ga = new GlideAjax('x_prdr_rig_staff.RigCrewingUtilsAJAX');


TO: var ga = new GlideAjax('RigCrewingUtilsAJAX');


Hi Michael,



Blergh. Sorry I missed this. In your GlideAjax call, you do *not* need the "x_prdr_rig_staff" prefix. This is a Client Script within your scoped application, so you don't need to append your own scope name.



Update your Client Script, line 5, to remove the scope prefix:


var ga = new GlideAjax("RigCrewingUtilsAJAX");


I have done that...



Did I call the method incorrectly from the AJAX call.


Am I extending the Script Include object correctly?



find_real_file.png


find_real_file.png