can we call script include from business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:41 AM
if its yes, give me a example...
thanks
sanjay

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:44 AM
Hello Sanjay,
Refer the below thread may helpful to you.
Can we call a script include from a business rule
How to execute script include from business rule
How to call script include from business rule
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:45 AM
Hello Sanjay,
Yes you can call script include from a business rule.
ex:
- function onAfter(current, previous) {
- var wsClient = new scriptincludenamehere();
- wsClient.process();
- }
Below links will be handy,
How to execute script include from business rule
Problem calling a Script Include from a Business Rule
Using Business rule to run script include in the background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:46 AM
Yes you can call.
BR :
(function executeRule(current, previous /*null when async*/) {
var obj = new SI name();
SIname.functionname(current, previous);
})(current, previous);
use SI : SI name
var SI name= Class.create();
SI name.prototype = {
initialize: function() {
},
functionname: function(current, previous) {
try {
}
catch(e) {
gs.log(e.message);
}
Please mark correct and helpful.
Regards,
Parvinder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:46 AM
Hi Sanjay,
To execute a script include from Br you just need to create an object of that script include(which is typically a class) and call the function of that script include with the object.
eg, script include - MyScript
function in the script incldue - myfunction()
in the Br just write
var x=new MyScript();
x.myfunction();