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

yuvasena
Kilo Contributor

Hi sanjiv could you help me another query ?



incident table its not working. please if you know tell me.


yuvasena
Kilo Contributor

Error showing like this : org.mozilla.javascript.NativeArray@dfaa31


The only reason is, you are directly accessing the array's object try converting it to string first.  


var str= list.toString();


Use, str later.


yuvasena
Kilo Contributor

find_real_file.png



I am adding this code still not working?


could you help me?


no, its var list[]; instead of var str=...



then convert to string var str= list.toString(); outside the while loop.


Then you can use current.watch_list=str;