- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 11:37 PM
Hi All,
Can any one explain how to call script include from business rule. please explain the differences between ondemand /classless , extend an exising class and define a new class.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:25 AM
Script Includes are ondemand reusable server side code.
Class based where you define something like this:
var NewInclude =Class.create(); NewInclude.prototype={ initialize :function(){}, myFunction :function(){//Put function code here}, type :'NewInclude'};
Call this in your BR as:
var foo =new NewInclude(); foo.myFunction();
Classless: is basically you create when your SI has only single function in case of mutplie functions in your SI you should define Class full.
For calling SI via client script you should use GlideAjax API.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 11:39 PM
Hi Kalpana,
1. https://www.youtube.com/watch?v=T9x4ZXAVurE
2. https://hi.service-now.com/kb_view.do?sysparm_article=KB0683128
- Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 11:46 PM
Hello,
In BR,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:15 AM
Hi Kalpana,
sharing few links for help; they should definitely guide you in right direction
https://www.basicoservicenowlearning.in/2019/12/script-include-servicenow.html
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:22 AM
Hi Kalpana,
Adding to Pratiksha, There are basically 3 types of Script Includes in ServiceNow.
1) Client-Callable Script Include( Classless): Classless Script Includes will generally contain a single function definition, as shown below for the function getMyTitle(). However it is possible to define multiple functions within the same Script Include.
2) Script Include with class :
Defining a Script Include with a Class may seem more complex at first, but ServiceNow actually provides the initial code stub upon naming the record. Shown below is a basic Classdefinition.
3) On Demand Script Include : A Script Include that defines a single function is known as an on demand, or classless, Script Include. The function is callable from other server-side scripts. On demand Script Includes can never be used client-side even if the Client callable option is selected.
It is critical that the Script Include name is an exact match for the name of the function. In the example, both the Script Include and the function are named sumTwoNums.
If my answer helped you in any way, mark answer as helpful and correct.
Thanks and regards,
Megha.
var si = new MyScriptInclude();
si.myMethod();
Script Includes are reusable server-side script logic that define a function or class. Script Includes execute their script logic only when explicitly called by other scripts. There are different types of Script Includes:
For more information, Click here
If answer is helpful please mark correct!
Thanks,
Pratiksha