Script include in ServiceNow is use to perform server-side scripting in ServiceNow. We can write java script functions and classes in script include. We can use those java script functions and classes written in script include is another server-side script such as business rule, script action etc.
There are three ways we could use Script includes in:
a) Class Script Includes
b) Classless Script Includes
c) Hybrid Script Includes.
There are two types of function in script include:
Private function:
Private function in script include is basically which is not accessible from client side. Private functions should have prefix " _".
Public function:
Private function in script include is basically accessible from other scripts.
What is gs.include() ?
If we want to call another script include within existing script include or current script include then we use gs.include("name of other script include").
gs.include("ScriptIncludeName")
How to call Script from Server Side Code(Business rule, Reference qualifier, Scheduled Job)?
new ScriptIncludeName().functionName()