When you put @mentions in Additional Comments It adds that user to Watch List

Kevin M1
Kilo Contributor

I am looking to have it when you put @mentions in additional comments it will take check that users sys_id and add them to the Watch List which would display their Name. If the user is already added to the Watch List I would not want them to be added a 2nd time. I believe this can be completed through a Business Rule but not really sure where to start. 

 

If anyone could assist me with this I would be greatly appreciated.

 

Kevin Maiberger

Kevin.Maiberger@transplace.com

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Curious about this one, I give it a go myself. Ending up with a working business rule! Only part: you don't instantly see the watch list updated, only on refresh 😞 Though the users are added, and added only once.

find_real_file.png

find_real_file.png

var grTable = new GlideRecord(current.table);
grTable.get(current.document);

 if(grTable.watch_list.indexOf(current.user) == -1) {
	grTable.watch_list += ',' + current.user; 
	grTable.update();
 }

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

8 REPLIES 8

Maybe I found the error... I tested with values in the watch list. Not with an empty watch list.

Added || !grTable.watch_list to the if statement, now works.

	var grTable = new GlideRecord(current.table);
	grTable.get(current.document);

 	if(grTable.watch_list.indexOf(current.user) == -1 || !grTable.watch_list) {
		grTable.watch_list += ',' + current.user; 
		grTable.update();
 	}

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

That is working for me for Single @mentions but if I have 2 then its only adding 1 of the users I have @mentions

 

In the screenshot below I have @Xavier Abaunza & @David Akers

- Its showing both have been added to Watch List in comments but not actually displaying both in Watch List.

 

find_real_file.png

 

Outside of this small issue its working great. 

Hmmm nice finding. I changed the Business Rule to after, instead of async. And tested with adding 1, 2, 3 @mentions, seems to work.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank you so much!!! That is working perfectly.

 

I have Marked as Correct Answer.

 

Again thank you so much for your work on this!

Kevin Maiberger