Need help with Business Rule to insert members to watchlist on Incident

babarat1
Tera Contributor

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

babarat1_0-1701259596780.png

 

2. It should update the watchlist of that Incident with the members who belong to a related list 

babarat1_1-1701259709838.png

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

Danish Bhairag2
Tera Sage
Tera Sage

Hi @babarat1 ,

 

Can u help me with the table name where that Watchlist information is stored which is highlighted in 2nd image.

 

Thanks,

Danish

 

Hi Danish,

 

1st table is Incident

2nd table Name is "u_watchlist" - custom

Thanks for the reply

Tai Vu
Kilo Patron
Kilo Patron

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

babarat1
Tera Contributor

Thank you so much. I will try the same