Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Calling a private scope script include with scoped app

Monish2
Tera Contributor

Hi ServiceNow Experts,

I am developing a scoped app and have a requirement of executing a script include which is only accessible from a particular scope. This SI needs an input param to be passed dynamically every time scoped app is executed. The scope of SI cannot be changed to "accessible to all scopes".

What are ways of executing this SI from a scoped app?

 

Thanks!

8 REPLIES 8

Hm, even though you have found a solution, can you tell us why you go with this solution instead of creating a 'Accessable from all scopes' Script Include of this scoped app? 
IMHO this would be a better way than having a changing sys_properties record (you will cause for lots of sys_update_xml records!).

Depends of course on your business case, but it would still be a good idea to explain to future readers why this solution is best for your business case đꙂ

Reason why I am not changing the scope to "Accessible from all scopes" is because the SI is ServiceNow OOB SI and don't want to play with it.  

 

Totally understandable, but you could create a new Script Include that acts as a wrapper for this.

You could also do this, given that OOTBSCRIPTINCLUDE is the name of the Script Include you dont want to touch, and MYSCRIPTINCLUDE is the name of the 'Accessable from all scopes':

var MYSCRIPTINCLUDE = Class.create();
MYSCRIPTINCLUDE.prototype = Object.extendsObject(OOTBSCRIPTINCLUDE, {
    type: 'MYSCRIPTINCLUDE'
});

Simon Christens
Kilo Sage

You can also make a script include in the same scope as the private script include (global ?) that is callable from all scopes.
From that script include you then call the private script include.

That should work