(function executeRule(current, previous /*null when async*/ ) { // Adds the New Assigned to, to the Watch list if they are not already on it. /* The watch list is a single string of sys_id's of the users in it. To add to it, we need to turn it into an array of strings so we can add the new Assigned to, to the array. We then have to turn the array back into a single, comma separated string. */ var arr = current.watch_list.split(','); // Turn current watch list into an array. var contact = current.assigned_to; //New assigned to var arrayUtil = new ArrayUtil(); //Create an ArrayUtil object to use it's functions. var contains = arrayUtil.contains(arr, contact); //Find out if the watchlist already has this Assigned to in it. //gs.addInfoMessage("Contact type of contact is: " + typeof(contact)); if (arr == undefined) { //if arr == undefined, then the Watch List is empty so we need to add the first person differently. //gs.addInfoMessage("arr == undefined"); current.watch_list = contact; } else if (!contains) { //The watch list has at least 1 entry so, if the new Assigned to is not on it, the we can add them. //gs.addInfoMessage("arr has data"); arr.push(contact); current.watch_list = arr.join(); } })(current, previous);