Watch list

yuvasena
Kilo Contributor

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;

}

1 ACCEPTED SOLUTION

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


View solution in original post

25 REPLIES 25

Sharique Azim
Mega Sage

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


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


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


Hi Pavan



Are we on the same page?


Please check the below screenshots



find_real_file.png


find_real_file.png


find_real_file.png




I think, the steps provided by my sufficient..