How to capture the watch list value in a variable in servicenow

phr
Tera Contributor

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?

phr_0-1721930195944.png

 

 

 

 

5 REPLIES 5

Voona Rohila
Kilo Patron
Kilo Patron

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

phr
Tera Contributor

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.

phr_0-1721932111206.png

 

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

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