Copy Existing Values and Add New to Watch List onChange

Sofija
Giga Expert

Hi All!

I was hoping maybe someone encountered the same issue or would be able to help regarding watch list.

I currently have client script running to add specified email based on incident priority selected. However, once user chooses to change the priority - the existing watchlist is replaced with the new value defined in the client script.

What I would like it to do is:

1) Replace one email DL with another based on priority

AND

2) Copy all other users added to the watch list which not need to be replaced by the new value

I tried to modify the client script to copy existing value and replace just one of them, but I feel stuck

I hope I am making myself clear, but if no please let me know and I will try to be more detailed and specific

Thank you in advance!

Kamile

1 ACCEPTED SOLUTION

Those should be fine.   It is because I used the same variable names.   You could change the names, or you could pull newWl up to the top and do this:



  1. var wl = g_form.getValue('watch_list');
  2. var newWl = '';
  3.   if (newValue == 1 ) {  
  4.   if(wl.indexOf("email2@email.com") > -1){  
  5.   newWl = wl.replace("email2@email.com", "email@email.com");  
  6.   }else{  
  7.   newWl = wl + ",email@email.com";  
  8.   }  
  9.   /*var alist = g_form.getValue('watch_list');
  10.   var arrlist =   alist.split(",");
  11.   arrlist.push("email@email.com");
  12.   g_form.setValue("watch_list", arrlist);*/  
  13.   g_form.setValue("watch_list", newWl);  
  14.   }  
  15.  
  16.   if (newValue == 2) {  
  17.   if(wl.indexOf("email@email.com") > -1){  
  18.   newWl = wl.replace("email@email.com", "email2@email.com");  
  19.   }else{  
  20.   newWl = wl + ",email2@email.com";  
  21.   }  
  22.   /*var alst = g_form.getValue('watch_list');
  23.   var arrlst =   alst.split(",");
  24.   arrlst.push("email2@email.com");
  25.   g_form.setValue("watch_list", arrlst);*/  
  26.   g_form.setValue("watch_list", newWl);  
  27.   }  

View solution in original post

10 REPLIES 10

Those should be fine.   It is because I used the same variable names.   You could change the names, or you could pull newWl up to the top and do this:



  1. var wl = g_form.getValue('watch_list');
  2. var newWl = '';
  3.   if (newValue == 1 ) {  
  4.   if(wl.indexOf("email2@email.com") > -1){  
  5.   newWl = wl.replace("email2@email.com", "email@email.com");  
  6.   }else{  
  7.   newWl = wl + ",email@email.com";  
  8.   }  
  9.   /*var alist = g_form.getValue('watch_list');
  10.   var arrlist =   alist.split(",");
  11.   arrlist.push("email@email.com");
  12.   g_form.setValue("watch_list", arrlist);*/  
  13.   g_form.setValue("watch_list", newWl);  
  14.   }  
  15.  
  16.   if (newValue == 2) {  
  17.   if(wl.indexOf("email@email.com") > -1){  
  18.   newWl = wl.replace("email@email.com", "email2@email.com");  
  19.   }else{  
  20.   newWl = wl + ",email2@email.com";  
  21.   }  
  22.   /*var alst = g_form.getValue('watch_list');
  23.   var arrlst =   alst.split(",");
  24.   arrlst.push("email2@email.com");
  25.   g_form.setValue("watch_list", arrlst);*/  
  26.   g_form.setValue("watch_list", newWl);  
  27.   }  

Brilliant - this worked! Thank you


venkat2
Kilo Expert

Hi,


If its possible can you share your script or include it in a demo instance.



Venkat


Uncle Rob
Kilo Patron

Lets make sure of something first.   You have separate distribution lists depending on the priority that want to be updated on every Comment to the Incident?


I have two separate DLs for two different priorities that need to be auto added (in total there are five priorities but others dont require DLs to be populated). When there is a change from critical to high priority, or viceversa, the two emails should switch places (and they do now) and keep all other users or emails added to the watch list (does not work).