Hide Variable based on Select Box choices

David Boom
Tera Contributor

I have a select box variable with multiple choices, I need to show other variables based on select box choices.

  • If choice A is selected, variable AB and AC should be visible.
  • If choice B is selected, only variable AB should be visible.

Am able to achieve the condition through onChange client script but when I select A first and then B, it is not hiding AC.

 

if(choice == "A"){

g_form.setVisible('AB', true);

g_form.setVisible('BC', true);

}

 

if(choice == "B"){

g_form.setVisible('AB', true);

}

14 REPLIES 14

@Ankur Bawiskar Logic is not working, when selecting choice B after A, It's not hiding the variable AC.

@David Boom 

is that variable mandatory? if yes then it won't hide unless you make it non-mandatory

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

No, that variable is not mandatory

@David Boom 

then script should work fine.

please share your complete script here and what debugging did you perform

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@David Boom 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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