Notifying group/assignee when RITM commented

Cirrus
Kilo Sage

Good afternoon all

We have a number of catalogue items that generate change requests, and we would like to notify the assignment group/assignee when the RITM is commented. I have the following business rule which works fine when the assigned to is populated:

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

var email_to =[];
var chg = new GlideRecord('change_request');
chg.addQuery('parent',current.sys_id+'');
chg.query();
while (chg.next()){
if (chg.assigned_to){
email_to.push(chg.assigned_to);
}
}

gs.eventQueue("change.commented", current, email_to.join(), gs.getUserName());
})(current, previous);

I need to know how to add an else{} statement to this script which will convert the assignment group members to a string and email them all if the change is unassigned. I have tried the following, but its not working:

 else{
var list = current.assignment_group.u_managers.toString();
var listArr = list.split(',');
for (var i=0;i<listArr.length;++i) {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',listArr[i]);
user.query();
if(user.next()){
email_to.push(user.sys_id.toString());
}

Any help greatly appreciated. 

6 REPLIES 6

on your template try changing URI_REF to URI

find_real_file.png

Cirrus
Kilo Sage

Thanks again Mike. Tried that, but it changes from RITM0000000 to LINK and if I click on the link it still takes me into the RITM

find_real_file.png