The CreatorCon Call for Content is officially open! Get started here.

How to make a field appear based on value of another field.

mateusz3
Mega Contributor

Hi Guys,

I am struggling with this one.

I have two fields on the form:

-Difficulty

-New Ticket

What I need to do is to make the New Ticket field hidden on the form unless the difficulty field is Level 2

find_real_file.png

find_real_file.png

Any advice?

Regards

1 ACCEPTED SOLUTION

I would recommend using UI policy option here.


When possible, consider using a UI policy instead of a client script for these reasons:


  • UI policies have an Order field to allow full control over the order in which client-side operations take place.
  • UI policies do not require scripting to make a field mandatory, read-only, or visible.

http://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices#Use_UI_Policies_Instead_of_C...


View solution in original post

8 REPLIES 8

jarodm
Mega Guru

Matt, You're going to want to look into UI Policies for that form.



Example: Create a UI policy


snehabinani26
Tera Guru

Hi Matt,



You can have an ONchange client script.



check if the newValue == "Level 2", make the New Ticket visible by g_form.setDisplay("field_name",true);


else g_form.setDisplay("field_name",false);



Or write a Ui Policy even for on load if the value is not Level 2 then it should not be displayed and reverse if value condition


I would recommend using UI policy option here.


When possible, consider using a UI policy instead of a client script for these reasons:


  • UI policies have an Order field to allow full control over the order in which client-side operations take place.
  • UI policies do not require scripting to make a field mandatory, read-only, or visible.

http://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices#Use_UI_Policies_Instead_of_C...


Hello Pradeep

 

I want to appear one field on the form which is on one table when the other field is true on another table can you suggest any scripts..

 

Thankyou!!!