Automatically add work notes contributors to the work notes list

klopez138
Kilo Explorer

Because of the way my organization has chosen to escalate incidents to sysadmins and netadmins, I need to figure out how to automatically add users in the System Administrators and Network Administrators groups to the work notes list. I've got every other element of the escalation model configured except for this part. Currently the netadmins and sysadmins have to manually assign themselves to the work notes list. Otherwise they won't get updates when the work notes are updated by other members of IT (help desk, other admins, etc.). The problem is, a lot of times they forget to add themselves to the work notes list so I'd like to automate that function but I CANNOT seem to figure out how to do it. Any help would be greatly appreciated.

Thanks

1 ACCEPTED SOLUTION

Okay, in that case, the modified script is



Step1: Create an BEFORE business rule and select advanced checkbox to true, insert and update to true


Filter condition : work notes | changes


Screen Shot 2017-06-02 at 12.25.13 PM.png


Step 2: Enter the below script in the business rule script section area.




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


  var watchList = current.work_notes_list.getDisplayValue();


  var caller = gs.getUserID();


  var out = watchList.search(caller);


  if(out == -1)


  {



  current.work_notes_list += ',' + caller;


  }


})(current, previous);


View solution in original post

12 REPLIES 12

Community Alums
Not applicable

Kevin,



Just to confirm, at what point do you want the NetAdmin and SysAdmin groups/group members to be added to the work notes watch list? Is it upon selection of a certain category (i.e Network, etc)? Or is it for every Incident that gets created in the system?



You can do this with a Business Rule, which would trigger on whatever condition meets your criteria. Then you can write a script to populate the work notes watch list with whatever groups or users you want.



Let me know if that makes sense; can probably provide example code if necessary.



Cheers,



TIm


We are "escalating" incidents by changing assignment groups and using an email action to notify the respective groups that an incident has been assigned to their group. The problem I'm facing is that once the incident is assigned to either netadmins or sysadmins and the admins enter work notes requesting data from the help desk technician who initiated the escalation, they aren't notified via email when the help desk provides the requested data. So I wanted to automatically add the netadmin or sysadmin that contributes to the work notes to the work notes list. That way they would receive any subsequent updates to the incident while avoiding the customers seeing any of the traffic between the help desk and admins. I hope that clarifies my question a little. If not, please feel free to ask for more data. Thanks for the assist, it's appreciated.



-Kevin


Community Alums
Not applicable

Yes, that clarifies, thanks for that. You could use the work notes list, implementing the script Pradeep supplied. Alternately, you can create a notification which sends an email to either the 'assigned_to' SysAdmin/NetAdmin notifying them of a new worknote. You can also do this at the group level (assignment_group). In some cases, if a SysAdmin or NetAdmin requests additional info from the HelpDesk, but they have not assigned the Incident to themselves (assigned_to is empty), then the group notification can let the entire SysAdmin or NetAdmin group know there has been a worknote added. That really depends on the internal process, though, and how certain groups choose to 'work' tickets.



I hope that makes sense!



Cheers,



Tim


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Kevin,



Create a BEFORE business rule with insert and update checkbox set to true and configure the filter conditions per your req.


Script is


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


  var members=[];


  var grpname = ['System Administrators','Network Administrators']; //PLEASE MAKE SURE GROUP NAMES ARE CORRECT


  for(i=0;i<grpname.length;i++)


  {


  var gr= new GlideRecord('sys_user_grmember');


  gr.addQuery('group.name', grpname[i]); //put your group name here


  gr.addQuery('user.active',true);


  gr.query();


  while(gr.next()){


  members.push(gr.getValue('user'));


  }


  }


  var new_memb='';


  if(current.work_notes_list.toString().length>0)


  new_memb=current.work_notes_list.toString()+','+members.join();


  else


  new_memb=members.join();


  current.work_notes_list =new ArrayUtil().unique(new_memb.split(',')).join();


})(current, previous);








Note: Please adjust group names in line 3rd per your req.