- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2015 08:33 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2015 05:21 AM
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:
- var wl = g_form.getValue('watch_list');
- var newWl = '';
- if (newValue == 1 ) {
- if(wl.indexOf("email2@email.com") > -1){
- newWl = wl.replace("email2@email.com", "email@email.com");
- }else{
- newWl = wl + ",email@email.com";
- }
- /*var alist = g_form.getValue('watch_list');
- var arrlist = alist.split(",");
- arrlist.push("email@email.com");
- g_form.setValue("watch_list", arrlist);*/
- g_form.setValue("watch_list", newWl);
- }
- if (newValue == 2) {
- if(wl.indexOf("email@email.com") > -1){
- newWl = wl.replace("email@email.com", "email2@email.com");
- }else{
- newWl = wl + ",email2@email.com";
- }
- /*var alst = g_form.getValue('watch_list');
- var arrlst = alst.split(",");
- arrlst.push("email2@email.com");
- g_form.setValue("watch_list", arrlst);*/
- g_form.setValue("watch_list", newWl);
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2015 08:42 AM
Can you post your script? That will help us provide feedback.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2015 08:55 AM
This is the original script (attempts to keep the users on watch list were removed so this is blank slate).
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 1 ) {
/*var alist = g_form.getValue('watch_list');
var arrlist = alist.split(",");
arrlist.push("email@email.com");
g_form.setValue("watch_list", arrlist);*/
g_form.setValue("watch_list", "", "email@email.com");
}
if (newValue == 2) {
/*var alst = g_form.getValue('watch_list');
var arrlst = alst.split(",");
arrlst.push("email2@email.com");
g_form.setValue("watch_list", arrlst);*/
g_form.setValue("watch_list", "", "email2@email.com");
}
if (newValue == 3 || newValue == 4) {
var watchlist = g_form.getValue('watch_list');
var newwatch = watchlist.split(",");
//alert(watchlist);
var outarr = [];
var arrayLength = newwatch.length;
for (var i = 0; i < arrayLength; i++) {
//alert(newwatch[i]);
if (newwatch[i] == "email@email.com" ||
newwatch[i] == "email2@email.com" ) {
} else
{
outarr.push(newwatch[i]);
}
}
g_form.setValue("watch_list",outarr);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2015 10:16 AM
I did this and it works:
var wl = g_form.getValue('watch_list');
if (newValue == 1 ) {
if(wl.indexOf("email2@email.com") > -1){
var newWl = wl.replace("email2@email.com", "email@email.com");
}else{
newWl = wl + ",email@email.com";
}
/*var alist = g_form.getValue('watch_list');
var arrlist = alist.split(",");
arrlist.push("email@email.com");
g_form.setValue("watch_list", arrlist);*/
g_form.setValue("watch_list", newWl);
}
if (newValue == 2) {
if(wl.indexOf("email@email.com") > -1){
var newWl = wl.replace("email@email.com", "email2@email.com");
}else{
newWl = wl + ",email2@email.com";
}
/*var alst = g_form.getValue('watch_list');
var arrlst = alst.split(",");
arrlst.push("email2@email.com");
g_form.setValue("watch_list", arrlst);*/
g_form.setValue("watch_list", newWl);
}
Play around with that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2015 01:39 AM
Hi Mike,
I tried using your example but I get errors of 'newWl' used out of scope and 'newWl' is already defined. Thoughts?
Note: I am using this on client script onChange and I am leaving the script starting if (newValue == 3 || newValue == 4) unchanged for clearing values.