How can I auto populate the watch list on an incident?

culk
Kilo Contributor

I'm trying to auto populate the watchlist on an incident on assignment based on 2 things 1) the assigned group and 2) the priority of a call. This is going to be a business rule for us.

My code isn't working yet and because of rustiness I can't figure out where I've gone wrong. Appreciate the help on this

addToWatchList();  

function addToWatchList() {

If   (current.sys_user_group == 'TeamName') {

  var wList = current.watch_list.split(',');    

  var addMe = current.u_escalation_assigned_to;  

  wList.push(addMe);      

  current.watch_list = wList.join(',');      

  current.u_escalation_assigned_to = '';

}

}

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi Sean,



Please try this out and let me know



addToWatchList();


function addToWatchList() {


if(current.assignment_group.getDisplayValue() == 'TeamName') {


  var watchlist = current.watch_list;  


  var addMe = current.u_escalation_assigned_to;


  current.watch_list = watchlist + "," + addMe;


  current.u_escalation_assigned_to = '';


}


}



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

6 REPLIES 6

Alikutty A
Tera Sage

Hi Sean,



Please try this out and let me know



addToWatchList();


function addToWatchList() {


if(current.assignment_group.getDisplayValue() == 'TeamName') {


  var watchlist = current.watch_list;  


  var addMe = current.u_escalation_assigned_to;


  current.watch_list = watchlist + "," + addMe;


  current.u_escalation_assigned_to = '';


}


}



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


I have assumed that this is an on before business rule and you would be selecting the assignment group on incident as TeamName and u_escalation_assigned_to is a user reference field on your incident.



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


Venkateswarlu K
Mega Guru

Hi


Sean


iTried this on my dev instance write a on before business rule for this



(function executeRule(current, previous /*null when async*/) {


    var cuser = current.assigned_to;//adding corresponding assigned to person and for caller replace this with caller_id


if ( current.watch_list.indexOf(cuser) == -1 )


{


var new_watch_list = current.watch_list.split(',');//+gs.getUserID(); //current.watch_list=current.watch_list+','+gs.getUserID();


new_watch_list.push(cuser);


current.watch_list = new_watch_list.join(',');



      gs.addInfoMessage('user will be added to watch list   succesfully');


}


})(current, previous);


Venkateswarlu K
Mega Guru

HI



may i know the status of ur thread in case if it is resolve then close the thread