How to set users to watch list automatically when choose certain category

AbdulAzeez
Mega Guru

Hello Everyone,

I have a requirement whenever i select a category of "Network" in incident table i must auto-populate 2 users name like user#1 , user#2 in watch list

Please help me out how to achieve this

1 ACCEPTED SOLUTION

Hi Abdul, IN client script use


var a = "sys_idof user1" + ","+ "sys_id of user 2";


g_form.setValue("watch_list", a)


View solution in original post

21 REPLIES 21

snehabinani26
Tera Guru

Write a before update BR in which validate the condition of Category changes to Network and in script


var watchlist = "user1sys_id" +","+"user2_sys_id";


current.watchlist = watchlist


Sneha,



I need to do it using Client Script:



I tried with below script but it is hittin an error can you please help me out what wrong i am doing:



onchange: Field Name:CAtegory



var cat = g_form.getValue('category');


  alert (cat);


  var us2 = new GlideRecord('sys_user');


us2.addQuery('user_name',natasha.ingram);


us2.query();



  if (cat == 'network')


  {


  g_form.setValue('watch_list', us2);


  }


if(newValue == 'network'){


var us2 = new GlideRecord('sys_user');


us2.addQuery('user_name','natasha.ingram');


us2.query();


if(us2.next()){


g_form.setValue('watch_list', us2.sys_id);


  }



See if this helps you.



Please note as per Best Practice you should not use GlideRecord in Client script


Thanks for the info Sneha,



Its working with your above script but how to add 2 users ?



And i tried with your BR but its not working