UI Policy is not working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 10:53 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 11:20 PM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 11:32 PM
Hi Siddharam,
In the UI policy please check you tick the "Reverse if false" checkbox.
Thank you!
Vishal Khandve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 11:39 PM
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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 11:46 PM
please use onChange client script for this and not UI policy
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2023 11:57 PM
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");
}