Hide/Show Fields depending on selection

Hi,

I'm modifying the scripts of the Company screen so that I can show/hide a field depending on the type of Company. The thing is that I have almost done it but there is one case in which it doesn't work.

I've created a new field and I've added it to the company screen. This field name is comp_tipoproveedor.
I want this field to be shown only if the company is a supplier.

I've set the OnChange script of the field comp_type with this code (so that it hides or shows my field depending on the selected comp_type):

If (this.value == 'Supplier'){

comp_tipoproveedor.style.visibility = 'visible';

_Captcomp_tipoproveedor.style.visibility = 'visible';

}

else {

comp_tipoproveedor.style.visibility = 'hidden';

_Captcomp_tipoproveedor.style.visibility = 'hidden';

}

In the comp_tipoproveedor field I've set the Create Script with this code (so that when you're viewing the screen it doesn't show the field if it's not a supplier):

If (Values("Act") == 200){

If (Values("comp_type") != 'Supplier'){

hidden = true;

}

}

The problem is that if I'm viewing a company that is a customer and I try to modify it, it shows my field although it's a customer and not a supplier.

I hope I've made myself understood.

Thanks in advance,
Vanesa

  • 0

    Hi Vanesa,
    As per your above post what I understand is that when you are trying to modify the “Customer” Type Company details, comp_tipoproveedor field should get hide instead of displaying. To resolve this issue, you need to call the “On Change” function on page load as well.
    Hope this helps!
    Regards,
    Dinesh