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

Hi Abdul, IN client script use


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


g_form.setValue("watch_list", a)


You need to do GlideAjax to fetch the data from sys_user table. If know the users be gonna same all the time then you can directly set the value to watchlist.


I need to set the same users as of now.



with above sneha script its working but i dont know how to add 2 users at a time


Hi Abdul,



Normally people tend to change their minds !!!, If you were go with onchange client script you will have to handle the people that could change their mind.



Walk through,



1. I have opened form at this point there are 3 other people in the watch list, and I have changed the category to "Network", If I understand your req correctly at this change you would want to see total 5 people in the watch list.


2. Before saving the form, I have changed my mind and went with other category =="Hardware" , so your client script has to delete the 2 additional users it added before.


3. But what if the 3 people that they were there during the form layout is actually is one of those whom you wanted to add and because of change in mind in the second step you do not want to delete the guy.



so basically, Before business rule might help to solve this problem little better .. but need to handle all of the above edge cases if you have to go with client script.




Happy Wednesday !!!


Shishir Srivast
Mega Sage

You can have onChange client script to set the value of watchlist.