- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2016 02:17 PM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2016 02:42 PM
Hi,
watch_list is an array list so you need to use the push function to insert an entry in an array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2016 02:23 PM
So I figured out my own answer and changed setValue to setDisplayValue via GlideRecord - ServiceNow Wiki and it set properly. This raises another question, how do I know when to use setValue and when to use setDisplayValue? When is something a reference field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2016 02:36 PM
Hi,
In case where we have fields refer/look up the external table to populate the information. In such cases we have options to set the field either by displayValue or the SetValue.
for ex: If i have reference field XYZ on the form referring to user table, then
- if i use setValue then i need to pass the sys_id of the user record.Like setValue('xyz',<sys_id for the user record>);
- i use the setDisplayValue then i need to pass the value of the field from user table where display attribute on dictionary in user table is true. let user ID field in user table have display true and "PQR User" iis a record in user table., use this setDisplayValue('XYZ',"PQR User");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2016 02:32 PM
I wanted to expand from my test case to my actual issue and it's not working. Can someone guide me here please? Here is the portion of my record producer script. Names have been changed to protect the innocent.
if(current.category == 'business_conversion' && current.conversion_name == 'Hi Line'){
var watch_list_conversion_users = ['Will Smith','Clark Kent','John Wayne']
current.setDisplayValue('watch_list',watch_list_conversion_users);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2016 02:42 PM
Hi,
watch_list is an array list so you need to use the push function to insert an entry in an array.