Adding to Watch List

sgmartin
Kilo Guru

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.  

13 REPLIES 13

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.

sgmartin
Kilo Guru

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(); 

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();

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.

sgmartin
Kilo Guru

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.