How do I automatically add the opened by field user to the watch list and work notes list on a record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 03:06 PM
I'm trying to figure out how do I automatically add users from the opened by field to the watch list on a record producer. I'm using the code below but I'm a little stuck at this point. Any help is needed. I'm new to scripting
current.watch_list = opened_by;
current.work_notes_list = opened_by;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 03:15 PM
Hey,
Write up a before business rule on the incident table
(function executeRule(current, previous /*null when async*/ ) {
var opened = current.getValue("opened_by");
current.watch_list = opened;
current.work_notes_list =opened;
})(current, previous)
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 02:02 AM
KB,
This is a duplicate of the following question.
ServiceNow community clearly states not to post the same question to several forums.
Be sure to post in the most relevant forum. Do not post the same post in several forums.
As I've answered in the other thread, try the following.
Filter Conditions: "Opened by" "is not empty"
(function executeRule(current, previous /*null when async*/) {
var openedBy = current.opened_by;
if (!current.watch_list.includes(openedBy)) {
current.watch_list += ',' + openedBy;
}
if (!current.work_notes_list.includes(openedBy)) {
current.work_notes_list += ',' + openedBy;
}
})(current, previous);