How can I set two fields to be mandatory, and have one hide and be null if the other has a value?

Alex Tagg
Tera Contributor

I have a form whereby I created 2 UI policies to hide a given field and set it equal to null, if the other has been populated and vice versa (see screenshots).

However I need them to both be mandatory prior to one being given a value. If I set their dictionary to mandatory, then the field that would have previously been hidden, no longer is when the other has a value. 

How can I set these to both be mandatory, until one has a value, and then hide? Is something missing from my UI policy script? Thank you

UI policy script logic is: 

function onCondition() {
   g_form.setDisplay('consumer', false);
   g_form.setValue("consumer", null);
}

 

find_real_file.png

2 REPLIES 2

Tudor
Tera Guru

Hi Alex,

You create another UI Policy with a lower order no(so that it triggers first) and set the fields mandatory.

Then in the UI policy script(mind you that this can be achieved with the UI Policy Action - both what you wrote and the additional requirements) you also add g_form.setMandatory("customer", false);

Please give it a try and provide feedback.

Tudor

Alex Tagg
Tera Contributor

Thanks for the above. Your logic was what I needed, but I also noted that no code was required and this could be done with Policy Actions only.