Populating a record producer watch list via script

will_smith
Mega Guru

I have a record producer that I want to add users to the watch list for the incident that gets created. I can populate the watch list with my name, but it doesn't reference my user object when I go to the incident and view the watch list. The details are blank, which means it's not really me.

The question before the community is this: how can I populate a watch list via server-side record producer script with names of users?

Thank you very much!

1 ACCEPTED SOLUTION

Hi,



watch_list is an array list so you need to use the push function to insert an entry in an array.


View solution in original post

6 REPLIES 6

found this off of the GlideRecord - ServiceNow Wiki   page. Is this what you were referring to? Except for the getDisplayValue() I would use set?



// list will contain a series of display values separated by a comma


// array will be a javascript array of display values


  var list = current.watch_list.setDisplayValue('Will Smith','Clark Kent','Superman');


  var array = list.split(",");


  for (var i=0; i < array.length; i++) {


        gs.print("Display value is: " + array[i]);


  }


I can't get this to push to the watch_list. Would you mind giving me a hand with the code rahuljain? I read through the correct answer on this thread and modified my code to match and it's not pushing. Adding users to watch list during a workflow based on variables entered by user.



var watch_list_conversion_users = ['Will Smith','Clark Kent','John Wayne']


watch_list.push(watch_list_conversion_users);