Business rule script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 10:43 AM
Hi All, Need help to write a BR where we have to add email id (example@gmail.com) when ever any case / incident will create for an specifce CI(configuration Item). Thanks all in advance. Regards, Sanjeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 03:17 PM
Hey there,
You should be able to accomplish this using a Business Rule where you conditions are:
Configuration Item <is> <the CI you need>.
In the script, you only need 1 line:
current.watch_list += ",example@gmail.com";
~Nick

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 07:17 PM
@Sanjeev Mishra Here is the script for an onBefore business rule which adds a specific email to watchlist if the incident is related to a specific CI.
(function executeRule(current, previous /*null when async*/) {
// Check if the record is related to the specific Configuration Item
var specificCI = 'sys_id_of_specific_ci'; // Replace with the sys_id of your CI
if (current.cmdb_ci == specificCI) {
// Add 'example@gmail.com' to the watchlist if it's not already present
var watchlist = current.watch_list.toString();
if (!watchlist.includes('example@gmail.com')) {
current.watch_list += ',example@gmail.com';
}
}
})(current, previous);