How to call script include from Business RUle

lucky6
Tera Contributor

How can we call script include from Business rule.Please providee syntax for that

11 REPLIES 11

Balaraju K B
Tera Expert

Example :

Script Include Name = My script

Function name in Script Include = myfunction()

var x=new My script();

x.myfunction();

 

Note : Otherwise you can use gs.includes in BR or above one by Creating the object of Script Includes in BR

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Lucky,

the syntax is simple

Refer example below

Script Include:

var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
    initialize: function() {
    },

	myFunction: function(){
		
		gs.info('Script Include called');
		
	},
	
    type: 'MyScriptInclude'
};

How to call from BR:

new MyScriptInclude().myFunction();

Regards
Ankur

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

May I know how can we get the response from Script include to Business rule.

Hi,

you can return value from the script include function and hold it in some variable and then use in BR

Regards
Ankur

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