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

Hi Pavan,



Can you please explain , what exact thing have you done? have you changed the reference table or did you create a business rule or a ref qualifier?


Thank you for help,



1.I have created business rule by using above script( for task table)


2.I will go through service-catalog and create new task then   auto populated the   users in watch list based on the group or script.


3.In that group some users are locked out.


4.but i need exact requirement is locked out users also showing in watch list. i need only active users in watch list.


5.i have try reference qul is active=true, but its not working.(its working only magnifier)



Thanks,


Pavan


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


Hi sanjiv,azim,



I have changed above script its working awesome.



but small help var list[], its showing error. how can modify?



with out var list[] its working good.



Thank you so much



Regards,


Pavan


I forgot the var list = []; equal to thing, updated the code, check again.