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.