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

Thanks you so much.great.


i dont need var,with out var its working good.



Regards,


Pavan


Strange that worked for you, but i would prefer to use var instead for any variable declaration.



Please remember to mark corrects answer and other formalities to close the forum.


Great Pavan. We always need to declare the array though. that is var list = [];



Please mark the thread answered to remove from unanswered list.



Please mark this response as correct or helpful if it assisted you with your question.

how to mark the thread. tell me pls



On 13-Jun-2017 7:54 PM, "sanjivmeher" <community-no-reply@servicenow.com>


Please check the below link



https://community.servicenow.com/docs/DOC-2244#correct



Please mark this response as correct or helpful if it assisted you with your question.