How to call script include in business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 10:28 PM
How to call script include in the business rule to trigger the notification to users. Please suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 11:26 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 11:30 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2024 08:26 PM
Best Solution , always Ankur is there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 11:18 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 11:23 PM
Hi,
Use the syntax
var ABC = new ScriptIncludeName().functionName(current);
also pass the parameters from your script.
Thanks,
Sumit