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

SanjivMeher
Kilo Patron
Kilo Patron

Can you try this

var snSupport = 'ServiceNowSupport@mycompany.com';
var lu = new ListUtil(current.watch_list);
gs.log('Final: list=' + lu.getList());
current.watch_list = lu.getList().toString();

Please mark this response as correct or helpful if it assisted you with your question.

Mark Stanger
Giga Sage

I don't see anywhere that you're calling 'addToList'.  I think you need to do this...

var snSupport = 'ServiceNowSupport@mycompany.com';
var lu = new ListUtil(current.watch_list);
lu.addToList(snSupport);
current.watch_list = lu.getList();

Good catch. But I think it can be done much easier way, if you just need to add a email.

 

var snSupport = 'ServiceNowSupport@mycompany.com';
current.watch_list.push(snSupport);

Please mark this response as correct or helpful if it assisted you with your question.

sgmartin
Kilo Guru

Yes, that was just stupidity on my part.  I just failed to copy/paste that line.

var snSupport = 'ServiceNowSupport@mycompany.com';
var lu = new ListUtil(current.watch_list);
lu.addToList(snSupport);
current.watch_list = lu.getList();