Need help with Business Rule to insert members to watchlist on Incident
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 04:41 AM
Hi @babarat1 ,
Can u help me with the table name where that Watchlist information is stored which is highlighted in 2nd image.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 05:25 AM
Hi Danish,
1st table is Incident
2nd table Name is "u_watchlist" - custom
Thanks for the reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 06:23 AM
Hi @babarat1
Let's create a Before Insert/Update business rule in the Incident table.
Advanced checked
Conditions could be Configuration Item changes AND Configuration Item is not empty.
And you can query to the Watchlist table > get the users > fill into the watch list field in the Incident record.
Sample.
(function executeRule(current, previous /*null when async*/) {
var user_ids = [];
var grWatchlist = new GlideRecord('u_watchlist');
grWatchlist.addQuery('u_ci', current.getValue('cmdb_ci')); //replace your u_ci field name in the watchlist table
grWatchlist.query();
while(grWatchlist.next()){
user_ids.push(grWatchlist.getValue('u_user')); //replace your u_user field name in the watchlist table
}
current.watch_list = user_ids.join(',');
})(current, previous);
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 06:33 AM
Thank you so much. I will try the same