- 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-05-2017 03:16 AM
Hi Pavan,
Can you please update code to:
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") )
{
list.push(grpMembers.getValue('sys_id')); // this captures all sys if of the records of sys_user_grmember table, you can also replace 'user' for user's sys id
// wL=sys_id' + ","+'Shana Sessler' ;
// current.watch_list = wL;
}
current.watch_list=list; // outside the while
This whole code sets the user in the watch list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2017 03:21 AM
But again, if the intention is to not show inactive users for future user i would have set the reference qualifier of the watch list field as active true , while the reference table is sys_user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2017 11:18 PM
Hi azim,
Thanks for response.
I have added reference qualifier and active = true but still showing inactive users.
Please suggest if any else?
Thanks,
Pavan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2017 11:58 PM