Need help with Business Rule to insert members to watchlist on Incident
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 04:10 AM
The requirement is as follows:
1. When a new Incident is created with a specific CI or if an Incident is updated with a specific CI as shown below
2. It should update the watchlist of that Incident with the members who belong to a related list
Related list - Watchlist table : u_watchlist
@
Need help with same
TIA
@Ankur Bawiskar @Danish Bhairag2 @Tai Vu @Sandeep Rajput @Dr Atul G- LNG
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 07:21 AM
Hi @babarat1 ,
Can you try this:
(function executeRule(current, previous /*null when async*/) {
// Query the u_watchlist table for members related to the specific CI
var watchList = new GlideRecord('u_watchlist');
watchList.addQuery('u_ci', current.cmdb_ci);
watchList.query();
// Loop through the members and add them to the Incident watchlist
while (watchList.next()) {
current.watch_list += watchList.u_member + ',';
}
// Update the Incident record
current.update();
})(current, previous);
Remember to replace 'u_ci' and 'u_member' with the actual field names in your 'u_watchlist' table.
Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul
Thanks and Regards,
Rahul