Adding to Watch List
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 09:54 AM
Got something that is driving me crazy now for a couple days.
Created a secondary List Collector in my Service Request that is pointing to a custom table for the user to select Distribution Lists to be added to the Watch List. I'm using Chuck Tomasi's script include ListUtil and it appears to be doing exactly what it's supposed to do. I've added numerous gs.log lines so that I can see what's going on. I've put all this within a Business Rule (before insert) on the sc_req_item table.
var snSupport = 'ServiceNowSupport@mycompany.com';
var lu = new ListUtil(current.watch_list);
gs.log('Final: list=' + lu.getList());
current.watch_list = lu.getList();
In the log I see this entry:
Final: list=634092984fb293000cb076601310c767,f38c579c4f17c6000cb076601310c70f,ServiceNowSupport@mycompany.com
But when I submit the SR and look in the email log, the additional email did not get added.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 10:09 AM
So does the 'SNSupport' email show up in the watch list or not? Trying to decide if this is an issue with your script or with email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 11:05 AM
None of these worked. It's just not getting added to the watch_list.
Tried:
current.watch_list.push(snSupport);
current.watch_list = lu.getList().toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 11:10 AM
Try this...
var snSupport = 'ServiceNowSupport@mycompany.com';
var wlArr = current.watch_list.split(',');
wlArr.push(snSupport);
var uniqueArray = new ArrayUtil().unique(wlArr);
current.watch_list = uniqueArray.join();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 11:19 AM
Can you also try
current.watch_list = current.watch_list+','+'ServiceNowSupport@mycompany.com';;
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 11:19 AM
Interesting this is, with this code:
lu.addToList(snSupport);
gs.log('Final: list=' + lu.getList());
current.watch_list = lu.getList();
gs.log('Current Watch_list: ' + current.watch_list);
I get this:
Current Watch_list: f61e42984fb293000cb076601310c7fc,f38c579c4f17c6000cb076601310c70f,ServiceNowSupport@mycompany.com
Which tells me it's successfully being added to the current watch list, but when the actual insert happens, something is missing.
I'll give you're suggestion a try Mark.