How to call script include in business rule?

sruthig
Tera Expert

 

How to call script include in the business rule to trigger the notification to users. Please suggest.

 

 

 

 

 

13 REPLIES 13

Hi,

place the entire BR script inside script include function

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

	myFunction: function(current){
		var st = current.getValue("state");
		if(st=='3') {
			var x= current.vendor_contact.email.toString();
			gs.eventqueue("event_name(used in notification)",current, x ,"");
		}
		else{
			var y= current.assigned_to.email.toString();
			gs.eventqueue("event_name(used in notification)",current, y ,"");
		}
	},

	type: 'TriggerEvent'
};

BR:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	new TriggerEvent().myFunction(current);

})(current, previous);

Regards
Ankur

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

Hi Ankur,

My script include is not only for a single notification. This is for all the notification.

So I can't edit the script include. Script include is used to send notification based on users preferred language.

 

Regards,

Sruthi

Best Solution , always Ankur is there. 

Hi Ankur,

Please suggest the above.

I have 2 notification and 2 events based on the lanuage. I have added lanuage value as the end of the notification name and event name like -en, -co. 

Please suggest how should I call script include in business rule and add event in business rule.

Regards,

Sruthi

chsumit
Kilo Expert

Hi,

Use the syntax

var ABC = new ScriptIncludeName().functionName(current);

also pass the parameters from your script.

 

Thanks,

Sumit