How to capture the watch list value in a variable in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 10:56 AM
Hi All,
How to capture watch list value in a business rule via variable
I did write the code
var watch= current.watch_list;
But the variable "watch" isn't capturing the watch list vale.
How to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 11:06 AM - edited 07-25-2024 11:07 AM
Hi @phr
The line you are using works, How are you using the watch variable in your code?
var watch= current.watch_list;
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 11:29 AM
Hi @Voona Rohila ,
Yes i am using the watch variable in the business rules to send the notification . But how ever when the watch list user updates the worknotes the notification associated with the business rule isn't triggering .
Here is the code that i have written.
It is triggering only to the impacted user as per the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 11:31 AM
Watchlist value will be the list of sys_id's and you are checking with updated by( which is a userID of the user)
You have to query user table to get list of watchlist userID's or updated by sys_id
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 11:45 AM
Something like this
var grUser = new GlideRecord('sys_user');
var watch= grIncident.watch_list;
grUser.get('user_name',current.sys_updated_by)
if(watch.indexOf(grUser.sys_id.toString())>=0)//if updatedby is part of watchlist
{
//entering
}
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP