UI Policy is not working?

Sid_Takali
Kilo Patron
Kilo Patron

Hi all,

I have created an UI Policy to make a field visible based on reference field condition. When a reference field has certain value then a field should be visible. This is working when I save a form but I need this should work on reference field value change. 

Ex. Fields B and C should be Visible only when I select Reference Field Value as a A. This is working only when I save the form but I need this onChange of reference value.

10 REPLIES 10

shivangi k
Kilo Sage

Hi @Sid_Takali 

 

You can achieve this through OnChange client script:

 

if(g_form.getValue("refernce field name")=='A')

{

g_form.setVisible('B',true);

g_form.setVisible('C',true);

}

 

else{

g_form.setVisible('B',false);

g_form.setVisible('C',false);

}

 

Regards,

Vishal Khandve
Kilo Sage

Hi Siddharam,

 

In the UI policy please check you tick the "Reverse if false" checkbox.

 

Thank you!

Vishal Khandve

venkatesh28
Tera Contributor

Hi Siddharam,

 

If you are using UI policy, the problem is you cannot add the conditions as 

1. Reference field changes 

AND

2. reference field changes to A

 

My suggestion is to use an OnChange client script with sys_id of the reference field value, than an UI policy for this scenario.

 

You can share the UI policy configured, will try to help!!

Ankur Bawiskar
Tera Patron
Tera Patron

@Sid_Takali 

please use onChange client script for this and not UI policy

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Eshwar Reddy
Kilo Sage

Hi Siddharam,

 

Create "on change" client script.

 

var a = g_form.getValue("reference field name");

 

if( a == "give the sysid of the reference field value") 

{

g_form.setDisplay("field name that you want to display");

g_form.setDisplay("field name that you want to display");

}