- 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-12-2017 06:15 AM
Hi azim,
Thanks again.
The thing is using script, once auto assigned the users in watch list then its showing still locked out users.
for magnifier its working fine but i need
1.using script some users are auto populated.(based on selection group)
2.that populated users are in locked out.then its still showing in watch list.
Regards,
Pavan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 06:34 AM
Hi Pavan,
Two things to note,
1. if the users are already added in the watch list , they first need to be removed from the list.
2. If your watch list only populates those users who are part of assignment group, then refer to the table sys_user_grmember not user table maybe.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 06:42 AM
Hi Pavan,
Try below.
var grpMembers = new GlideRecord("sys_user_grmember");
grpMembers.addQuery("group",current.assignment_group);
var list[];
grpMembers.query();
while(grpMembers.next())
{
if(current.assignment_group.getDisplayValue() == "Network Engineer" && grpMembers.user.active==true)
{
list.push(grpMembers.user);
}
}
current.watch_list=list; // outside the while
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-12-2017 06:52 AM
Hi Pavan,
Further as Sanjiv mentioned, if your approach is to also add the group members into the watch list i would have changed the notifications send to fields, rather creating new scripts.. But yes, if the requirement is also to add the user into the watch list for record purpose ,writing a business rule with the above code might help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 09:25 PM
Hi all,
I have added grpMembers.user.active==true but still showing locked out users.
Please let me know, if any other solutions are available?
Thanks,
Pavan