Repeated name appear in watchlist selection field

SoumyasreeP
Tera Contributor

Hi ,

While I am working on configuration of watchlist in incident form, i found my name is repeatedly coming under watchlist field.

Record producer script 

var memberIds = (producer.watch_list + '').split(',');

var userIds = [];
for (var i = 0; i < memberIds.length; i++) {
var id = memberIds[i].trim();
if (!id) continue;
var gr = new GlideRecord('sys_user_grmember');
if (gr.get(id)) {
userIds.push(gr.user);
}

}
current.watch_list=userIds.join(',');
current.u_watch_list = userIds.join(',');
why its not working?
11 REPLIES 11

Its not working when incident is getting created from portal and instance

yes

Tanushree Maiti
Tera Patron

Hi @SoumyasreeP 

 

If you have a script adding users to the watch list field in the Record Producer Script tab, update your script to prevent duplicating names and avoid adding yourself unnecessarily: 

 

var currentWatchList = current.watch_list.toString();
var userId = gs.getUserID(); // take it from your variable if (currentWatchList.indexOf(userId) == -1) { if (currentWatchList == '') { current.watch_list = userId; } else { current.watch_list = currentWatchList + ',' + userId; } }
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

SoumyasreeP
Tera Contributor

No its not working

Hi @SoumyasreeP 

 

Add log and debug it - which line not working.

 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti