- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2017 09:08 AM
Hi ,
i have added two users in watch list using below script but these users are inactive it will showing in watch list still.
Please tell me, if users are inactive how to remove from watch list?
(function onBefore(current, previous)
{
var grpMembers = new GlideRecord("sys_user_grmember");
grpMembers.addQuery("group",current.assignment_group);
grpMembers.query();
while(grpMembers.next())
{
if((current.assignment_group.getDisplayValue() == "Network Engineer") )
{
wL='Jacob Bourdon' + ","+'Shana Sessler' ;
current.watch_list = wL;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 11:31 PM
Hi Pavan,
Although, im not much in favor of using a BR, but then again if you want to complete it with a script then please use:
//code of sanjiv,modifed
var grpMembers = new GlideRecord("sys_user_grmember");
grpMembers.addQuery("group",current.assignment_group);
grpMembers.addQuery('user.active',true);
var list=[];
grpMembers.query();
while(grpMembers.next())
{
if(current.assignment_group.getDisplayValue() == "Network Engineer") // the group you want only to work
{
list.push(grpMembers.getValue('user'));
}
}
current.watch_list=list; // outside the while
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 12:16 AM
Thanks you so much.great.
i dont need var,with out var its working good.
Regards,
Pavan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 12:19 AM
Strange that worked for you, but i would prefer to use var instead for any variable declaration.
Please remember to mark corrects answer and other formalities to close the forum.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 07:23 AM
Great Pavan. We always need to declare the array though. that is var list = [];
Please mark the thread answered to remove from unanswered list.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 07:31 AM
how to mark the thread. tell me pls
On 13-Jun-2017 7:54 PM, "sanjivmeher" <community-no-reply@servicenow.com>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 07:43 AM
Please check the below link
https://community.servicenow.com/docs/DOC-2244#correct
Please mark this response as correct or helpful if it assisted you with your question.