Notification for Additional comments in Service Catalog task

mariapaskova
Kilo Contributor

Hello,

I'm experiencing an issue with a notification not sent to the task assignment group when a service catalog task is commented.

The Additional Comments section on the Catalog Task, is on   sc_task.request_item.comments

find_real_file.png

When I define the condition for "when to send", I don't see Additional comments in the list under Requested item fields.

find_real_file.png

I try to trigger the event with "Event is fired" instead of Insert/Update and defined a business rule on the requested item table, but it doesn't send the notification as well.

These are screenshots of the business rule, event registry and notification:

Notification:

find_real_file.png

Event registry:

find_real_file.png

Business rule:

find_real_file.png

If someone can help me with this issue will be great.

Thanks a lot in advance!

Maria

1 ACCEPTED SOLUTION

In the script where you trigger the event sc_req_item.commented you can add the following code:



var grpList = [];


var tsk = new GlideRecord('sc_task');


tsk.addQuery('request_item',current.sys_id);


tsk.addQuery('active','true');


tsk.query();


while (tsk.next()){


  grpList.push(tsk.assignment_group+'');


}



  gs.eventQueue("sc_req_item.commented",current, grpList.join(','),gs.getUserName());


View solution in original post

24 REPLIES 24

Hi Terri,



I set a notification in the RITM table:


find_real_file.png



find_real_file.png



A notification is sent to the person who opened the request and John Mack, but the assignment group doesn't receive it, as it is in the sc_task table.



Where do I need to set a script with parameter the assignment group? And what does the script should look like?


In the script where you trigger the event sc_req_item.commented you can add the following code:



var grpList = [];


var tsk = new GlideRecord('sc_task');


tsk.addQuery('request_item',current.sys_id);


tsk.addQuery('active','true');


tsk.query();


while (tsk.next()){


  grpList.push(tsk.assignment_group+'');


}



  gs.eventQueue("sc_req_item.commented",current, grpList.join(','),gs.getUserName());


BIG BIG THANK YOU Terri



The script works and the notification is sent to the assignment group



I'm posting some screenshots for the users who will read this thread in the future:



1. The notification is in the sc_req_item table and is triggered by an event:find_real_file.png



2. The event is run in the sc_req_item table and is fired by a Business rule



find_real_file.png



3. The Business rule includes the script for getting the task assignment group:



find_real_file.png



4. In the notification pass the event parameter:



find_real_file.png



And it works


This article was awesome.   Help me with my problem.   We have the same thing with the comments not sending notification to the assigned_to.   In the code I change the assighment group to assigned to.   IT WORKED.     But now the request.requested_for or opened by is not receiving notification.   What do I need to change.    


find_real_file.png



here is my entire code on the BR


if (current.operation() == 'insert') {


    gs.eventQueue("sc_req_item.inserted", current, gs.getUserID(), gs.getUserName());


}




if (current.operation() == 'update') {


    gs.eventQueue("sc_req_item.updated", current, gs.getUserID(), gs.getUserName());


}




if (current.operation() == 'update' && current.stage == "delivery") {


    gs.eventQueue("sc_req_item.delivery", current, gs.getUserID(), gs.getUserName());


}




if (current.operation() != 'insert' && current.comments.changes()) {


    var assigneeArr = [];


    var assignGroupArr = [];


    //Query for any non-pending, associated tasks


    var catTsk = new GlideRecord('sc_task');


    catTsk.addQuery('request_item', current.sys_id);


    //catTsk.addQuery('state', '!=', -5);


    catTsk.query();


    if(!catTsk.hasNext()){


          gs.addInfoMessage('This comment has been added but may not be viewed by technicians until work begins on the request item.');


    }


    while(catTsk.next()){


          //If we find tasks then get the assignees and notify them


          if(!catTsk.assigned_to.nil()){


                assigneeArr.push(catTsk.assigned_to.toString());


          }


          else{


                assignGroupArr.push(catTsk.assignment_group.toString());


          }


          //Add ITIL watch list users


          assigneeArr.push(catTsk.u_itil_watch_list.toString());


                //Add Group watch list users


          assigneeArr.push(catTsk.group_list.toString());


    }


  //Notify the assignees


    gs.eventQueue("sc_req_item.commented.itil", current, assigneeArr, assignGroupArr);


    //Notify the end-user


    gs.eventQueue("sc_req_item.commented", current, gs.getUserID(), gs.getUserName());


}




if (!current.assigned_to.nil() && current.assigned_to.changes()) {


    gs.eventQueue("sc_req_item.assigned", current, current.assigned_to.getDisplayValue() , previous.assigned_to.getDisplayValue());


}




if (current.stage.changes()) {


    gs.eventQueue("sc_req_item.change.stage", current, current.stage, previous.stage);


}


//DP - 04/19/17 added to test commment from RITM to TASK and to assignment group


var grpList = [];


var tsk = new GlideRecord('sc_task');


tsk.addQuery('request_item',current.sys_id);


tsk.addQuery('active','true');


tsk.query();


while (tsk.next()){


  grpList.push(tsk.assigned_to+'');


}



  gs.eventQueue("sc_req_item.commented",current, grpList.join(','),gs.getUserName());




screen shot of the notification.


find_real_file.png


I think I got it to working now.   I checked the box "Send to Event creator".   Now the assignee is getting the email and the requested for.