what is the use of gs.include()?

shabbir5
Tera Guru

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

@Ankur Bawiskar Please provide your inputs and do the need full help

7 REPLIES 7

Shailesh Bachha
Tera Expert

Hi @Shabbir ,

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

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?

Hi @shabbir ,

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

Ankur Bawiskar
Tera Patron
Tera Patron

@shabbir 

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader