Help understanding sc_req_item comment events business rule on RITM

LRhodes
Tera Guru

Hi - we're trying to understand how the following business rule works. We're trying to mimic the steps to see the part where the 'Comment cannot be viewed by technicians until work begins" message is displays for the end user.

How I read it is that when a new comment is added to the RITM via the Portal it will check to see if there are any active SC Tasks. If not then it should display this message. I can't seem to get it to display though. I've tried catalog items with no tasks, some with tasks which I've then moved into either pending or closed states, but I can't seem to get this message to display. Any advise?

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

function queueAssigneeEvent() {
   var assigneeArr = [];
   var assignGroupArr = [];
   //Query for non-pending sc_task records
   var catTsk = new GlideRecord('sc_task');
   catTsk.addQuery('request_item', current.sys_id);
   catTsk.addQuery('state', '!=', -5);
	catTsk.addEncodedQuery('stateNOT IN3,4,7');//(Closed Complete, Closed Incomplete, Closed Skipped)
   catTsk.query();
   if (!catTsk.hasNext()) {
      gs.addInfoMessage(gs.getMessage('Comment cannot be viewed by technicians until work begins on the Requested Item'));
      return;
   }
   while (catTsk.next()) {
      //notify task assignees
      if (!catTsk.assigned_to.nil())
         assigneeArr.push(catTsk.assigned_to.toString());
      else
         assignGroupArr.push(catTsk.assignment_group.toString());
      //Add Work notes watch list users
      assigneeArr.push(catTsk.work_notes_list.toString());
   }
   gs.eventQueue("sc_req_item.commented.itil", current, assigneeArr, assignGroupArr);
}
1 REPLY 1

Community Alums
Not applicable

Hi @LRhodes ,

This will help you :

https://community.servicenow.com/community?id=community_question&sys_id=4cfd07addb9cdbc01dcaf3231f9619a1

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep