How to call a global script include from now-sdk?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 06:48 AM
Hi now-sdk community,
I struggle to complete the following task: calling a global script include from my now-sdk scopped application.
When the following snippet runs well in a bg script (executed from my application scope):
var test = new global.inboundAPILog().insertEventLog('x_frt_orangetmf697.inbound.api.event', null, "","");The exact same script deployed through now-sdk will produce this error: "undefined is not a function".
Surprisingly, if I open the deployed sys_module in my browser, the global script include is well found, and I can navigate to it with control+click :

I haven't found any resources on this specific topic, does this speak to you?
Thanks a lot for your feedback,
Regards,
Anthony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 07:55 AM
Hi,
The target script include is accessible from all scopes (see attachment).
When i'm running the bg script, i'm running it from "x_frt_orange_sdk" scope, which is my now-sdk app scope (see second attachment).
I'll give a try to remove the global. prefix in my script source code and I'll keep you in touch.
Regards,
Anthony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 08:53 AM
Hey @anthonydian,
I believe you are trying to call the global script include from a module. To achieve that you could do the following,
import { global } from '@servicenow/glide'
export function someAPI() {
var test = new global.inboundAPILog().insertEventLog('x_frt_orangetmf697.inbound.api.event', null, "","");
//do something with the result
}
The module requires the import statement for it to resolve the scope and script include on the instance. Let me know if this fixes your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
How would this work if the script include is from a different scope than the global scope?
I am trying to use a script include exposed by a different application, but I cannot figure out how to use the import.
Also, could I expose a module from the other application, instead of a script include?
//Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @ChristianGraab,
first of all, such a script include must be accessible
and then if it is cross-scope then you just ened to add a scope prefix global.sandstormUtil as seen in the API name above.
so as example you would call it from other app using:
new global.sandstormUtil().yourFunctionName();
This reply is 100 % GlideFather and 0 % AI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @GlideFather
This that part works.
But let's say I want to use the a script include from another scope, I would do this in a regular Script Include or Background Script.
var util = new x_mycompany_appScope.loggingUtil().logStuff('message')
But I cannot figure out how to do this from the now-sdk app.
I have tried looking at the examples on github (https://github.com/ServiceNow/sdk-examples), but that didn't help me in understanding it better.
I have tried doing:
import { x_mycompany_appScope } from "@servicenow/glide";But this doesn't seem to be the correct way of doing it, since it just becomes undefined.
