Hiding fields using UI Policy

ceraulo
Mega Guru

Hello!

I have 4 fields - A, B, C, D.
On initial load of the form, only A is visible. 
Fields B, C, D becomes visible when a value is selected from A which is a reference field.

The requirement is to clear B, C, D of values then hide it when A is updated to empty or another value is selected.

I created a UI Policy that is triggered when A is empty and see photo below.
find_real_file.png

The above works but only if B, C, D have values. If it has no value, the values are cleared but the fields are still viisble.

Please help!

1 ACCEPTED SOLUTION

Hi,

Well, the solution would be to make them mandatory once field A has a value (using that same UI policy) = setting mandatory > true.

So remove the mandatory checkmark in each of the variables individually (if it's checked now, which I assume it is)...

THEN....when field A has no value, they aren't mandatory anymore thus they will hide...and then my small script above clears the values out of b,c,d.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

7 REPLIES 7

Manoj Kumar16
Giga Guru

Please write an OnChange client script on the field A

I also tried that using setDisplay but does not work. It works when using setVisible but it doesn't adjust other fields on the form. There is a big gap betwen Field A and other fields below Field D.

Allen Andreas
Administrator
Administrator

Hello,

Can you share a screenshot of your UI policy where these fields are set to show if A has a value?

You shouldn't need a second UI Policy to then hide these fields as the first UI Policy will do that for you (if you set those B, C, D fields to Visible = True, then anytime it's NOT true, they will auto-hide for you.

In the script section for the UI policy where they would show, in the "run if false" script section, you could add:

g_form.clearValue('field_b');
g_form.clearValue('field_c');
g_form.clearValue('field_d');

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

I have figured it out. There is no solution because setDisplay only work for fields that are not mandatory. The fields in my catalog item are all mandatory.