GlideAjax: Not able to access function inside script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2015 01:14 PM
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:
Corresponding Client Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2016 10:40 AM
Hi Michael,
Yes, you appear to be calling it correctly. I notice that you're using "new JSON()" in your Script Include. That should be "new global.JSON()" since the JSON Script Include is in the global scope. If you're on Helsinki, you could use "JSON.stringify(object_to_encode)" instead, since JSON is part of the ES5 enhancements added to Helsinki.
If you are on Geneva or older, you need to use the JSON Script Include, which lives in the global scope.
That should be showing up in your node log, when you try to run this code. You should be seeing errors about a missing global identifier. Note that the node log is different from the Script log.
That error could explain why the rest of the include fails to run.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 01:27 PM
Ok, I did what you suggested...
No luck!
We tried to put the exact same script in the Global App scope, and in the client script referenced the new script Include as global.RCUtilsAJAX.
It worked... Yippee... However not good, as now our app isn't self contained.
Any further ideas?
Regards,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 01:46 PM
Hi Michael,
This should be working. Can you send me a private message so we can set up a live debugging session?
Thanks
Cory

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2016 01:56 PM
Absolutely, as soon as I figure out how to PM, I will...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2016 07:25 AM
Hi Michael,
Sometimes it's the simplest things. In this case, it was the gs.log statements in your Script Include. I completely missed that earlier. gs.log is not available within Scoped apps. Instead, we have create new logging methods (gs.info, gs.warn, gs.debug, gs.error). Those are detailed here:
https://wiki.servicenow.com/index.php?title=Scoped_Script_Logging
Note that the variable substitution uses {0},{1} syntax (I think I tried $0,$1 when we were debugging, because it's early and I haven't had any coffee yet).
With that last change to your server-side Script Include, this should work as intended.
Thanks,
Cory