- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2014 02:38 PM
Came across a few examples where out-of-box code may reference gs.include('ScriptInclude');
But then what would be the difference (if any) in using
gs.include('ScriptInclude');
versus
var foo = new NewInclude();
I'm curious as to the differences and/or the advantages.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2014 12:08 AM
Hi Daniel,
gs.include() allows you to call a script include and use the functions in that script include within your current script include i.e you do not have to copy the functions into your current script include, but rather you can call them directly.
var foo = new NewInclude() initializes an object for the script include NewInclude. Now any function that you have defined within this script include class can be called directly using foo:-
eg:-
var NewInclude = Class.create();
NewInclude.prototype = {
initialize : function() {
},
myFunction : function() {
//do something
},
type : 'NewInclude'
};
Usage:-
var foo = new NewInclude();
foo.myFunction();
Thanks & Regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2014 11:28 PM
Hi Daniel,
- gs.include('ScriptInclude') is mainly used in Script Includes where you want to use the methods of that script include directly in current Script Include.
- So that there is no need to rewrite the same function in this SI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2014 12:08 AM
Hi Daniel,
gs.include() allows you to call a script include and use the functions in that script include within your current script include i.e you do not have to copy the functions into your current script include, but rather you can call them directly.
var foo = new NewInclude() initializes an object for the script include NewInclude. Now any function that you have defined within this script include class can be called directly using foo:-
eg:-
var NewInclude = Class.create();
NewInclude.prototype = {
initialize : function() {
},
myFunction : function() {
//do something
},
type : 'NewInclude'
};
Usage:-
var foo = new NewInclude();
foo.myFunction();
Thanks & Regards,
Hari

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2016 05:46 AM
Hi Harikrishnan,
I have a little doubt here.
So in my script include, i can use other script include's method, without instantiating the script include class, using gs.include(). is that it?
Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2020 12:11 AM
Check out this video, it will clear all your doubts and help you to understand Script Include And Ajax Call queries in details.
Link: https://www.youtube.com/watch?v=qNiYWMMzC2o&t=209s&ab_channel=ServiceNowHelpdesk
It help you to understand below points.
- Understand Script Include And Ajax Call
- When, How and in which scenario we will use it.
- Understand Synchronous (getXMLWait()) and aSysnchronous (getXML()) Ajax call and scenario based use of it.
Please mark reply as Helpful/Correct, if applicable. Thanks!!