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

I'm not well versed in scripting functions in servicenow but the above code looks to me like the entire group would be added? I just want to add the individual admin that contributed to the work notes. If I am incorrect in my assumption, I apologize.



Thanks,


Kevin


The script was based on the assumption that you want to add group members. So you mean that you want to add two individual users?


Is that correct?


No sir. I only want to add the individual who makes an entry into the work notes field of the incident. So anyone that enters work notes is automatically added to the work notes list.


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);


Pradeep,



                            That Worked!! Thank you so much for the assistance, It's greatly appreciated.



-Kevin