Solved

Hide a form control based on more than one drop-down option


I am trying to show/hide a control based on selections from a drop down list. Documents Drop down has 4 options - A, B, C, D and I need the control to show when either A or B is selected. I got it to work for A but when I add B using the OR (||) notation in my expression, form does not display at all. Please does anyone have ideas or alternative suggestions?

 

Expression reads thus:

Working

Documents!="A"

 

Not Working

Documents!= ("A" || "B")

Documents!="A" || Documents!="B"

icon

Best answer by samuel 28 May 2018, 05:14

View original

2 replies

Badge +3

Hi Soji,

There could be a few small gotchas in this case - here's how I've built out mine:


Below is a simple drop down called documents with choices A,B,C,D (NOTE: no spaces after the commas as " B" is not the same as "B"). I've made my secondary field that'll be shown/hidden a yes/no checkbox.


The configuration of the rule on the checkbox is as follows:

There is only once discernible difference to your impementation - the use of an && rather than a || , this makes sense when we walk through this logically. The way the When -> Then system works is the 'then' only executes when 'when' evaluates to true.

|| is the INCLUSIVE OR operator, meaning that if either side evaluates to true, the entire expression evaluates to true. This is obviously a problem as when we have A selected, the section for != B still evaluates to true, therefore the expression is true, thus the box is still hidden.

The && relies on both operands being true, otherwise it will evaluate to false. So now if we choose A, while the expression for A is still false and the expression for B is true, the overall && statement evaluates to false, therefore the then->hide is never executed.

Hope this helps,

Sam

Thanks Sam, you're a star. I had used a workaround due to time pressure for a demo (:D) but I've now updated the logic. The way Nintex evaluated the "&&" seemed counter-intuitive but on a closer look adds some robustness to the logic. Thanks again.

Reply