what is the use of gs.include()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 06:28 AM
Hi All,
what is the use of gs.include();
i got to know it is used to call a sript include , but to call a script include we can use new scriptincludename().functionname() rite ?
may i know the exact use case ?
for example i have the below script include
var testAOP = Class.create();
testAOP.prototype = {
initialize: function() {
},
sum:function()
{
var a=10;
var b=20;
var c=a+b;
return c;
},
type: 'testAOP'
};
so if i call this into a background script using gs.inlude('testAOP') i am getting out put as "true" , can anyone tell me the exact difference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 06:39 AM
Hi
gs.include() method is used to call Script include into another script include and use the function in that new script include instead of writing the same code again and again.
Regards,
Shailesh Bachhav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 06:50 AM
Thank you for the response Shailesh , so suppose if i called my script include testAOP into another script inlude using gs.include('testAOP') ,how i need to call the functions inside testAOP?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 11:44 AM
Hi
If you have many functions in your First Script Include and you want to call particular function in Second script include then instead of gs.include() method you can try
var obj = new First_Script_include();
obj.Required_function();
Regards,
Shailesh Bachhav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 06:49 AM
You can call another script include using gs.include('script include name'). Then you have access to functions present inside that script include.
check this link
gs.include() versus new ScriptInclude()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader