How to call Script Include from another Script Include?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2024 05:22 PM
How to call Script Include from another Script Include?
AND
how to call functions/methods from one Script Include to another Script Include functions/methods?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2024 08:26 PM
Hello @Sarah Bouil
In ServiceNow, Script Includes are reusable server-side JavaScript objects that can be used to store and share functions. To call one Script Include from another, you can follow these steps:
Let's assume you have two Script Includes:
Script Include A:
var ScriptIncludeA = Class.create();
ScriptIncludeA.prototype = {
initialize: function() {},
someFunctionA: function() {
// Your code here
},
// other functions in Script Include A
};
Script Include B:
var ScriptIncludeB = Class.create();
ScriptIncludeB.prototype = {
initialize: function() {},
someFunctionB: function() {
// Call function from Script Include A
var scriptIncludeA = new ScriptIncludeA();
scriptIncludeA.someFunctionA();
},
// other functions in Script Include B
};
Please mark the response as Accepted, if you find it helpful.
Regards,
Samaksh Wani