how to hide a control based on multiple values?

  • 25 March 2019
  • 9 replies
  • 19 views

Badge +4

i found this How To, the title of which describes what i want to do (i.e. hide using multiple choices/values) but it is not clear to me how to add the second choice to the structure and also as this was an Office365 solution, does this also work for Sharepoint 2013?

 

Rule-To-Hide-Panel-Based-On-Single-or-Multiple-Choices

currently I am using 1 rule with the condition:

not(Control1=="No")

 

and then have a second rule applied to the same control.

not(Control2=="Yes")

 

How would I do this using the structure suggested in the link or how can I use the "Or" function/operator to do the same and wrap up my two conditions into one?


9 replies

Badge +4

i believe my question is answered here:

 

Nintex-form-condition-rule-the-OR-rule

 

however when I try to apply the answer, the Preview of the form shows a blank page. 

 

Does anyone know what might be causing this?

 

thanks

 

john

Userlevel 4
Badge +11
Hi, if the preview is blank, usually there's a syntax error in the rules that causes the javascript to error (maybe you can try to remove the rules one by one in order to find the problematic one..)
Badge +7

Hello John,

 

Yes, I use the Or a lot. I prefer to use the inline function builder to do what I need to do.

 

I think is should look something like this:

The first part:

not(equals(Control1,'No')

 

Second part:

not(equals(Control2,'No')

 

And then put it together with the Or

Or(not(equals(Control1,'No')),not(equals(Control2,'No')))

 

Let me know if this works for you.

 

Kind Regards,

Francois Crous

Badge +4

thank you @fccrous , if I need to nest 3 criteria as the condition to be tested, do I need to include a tiered second 'or' in the structure?

 

currently I am using this but i'm not sure the precedence of the brackets so i don't know where to put the second 'or':

or(not(equals(Q9,'Yes')),not(equals(Q10,'Yes')),not(equals(Q11,'Yes')))

 

the rule i need to implement is if the answer to (Q9 or Q10 or Q11) is 'Yes' then show the panel, otherwise hide.

Userlevel 4
Badge +11
Hi,

yes, you need to nest an additional or because it allows only two condition inside it, so your formula should be something like

or(not(equals(Q9,'Yes')),or(not(equals(Q10,'Yes')),not(equals(Q11,'Yes'))))
Badge +4

Hi @jackgelo 

 

thanks a lot for replying. 

 

That's exactly what I have at the moment but it only shows (i.e. does not hide) the control when all three conditions are met and i realised it's probably the way i have specified the logic. At the moment (i think) I am effectively saying if Q9 does not equal yes then hide, which could still be true if Q10 = Yes, resulting in the control being hidden.

 

Effectively I need to change my rule to state the outcome in the requirement in the positive. Maybe I need to say something like if(and(not(equals(Q9,'Yes')),and(not(equals(Q10,'Yes')),not(equals(Q11,'Yes')))))

i'll try this and post if it works.

 

 

Badge +3

Try something like: If(equals(Q9,'Yes'),equals(1,0),if(equals(Q10,'Yes'),equals(1,0),if(equals(Q11,'Yes'),equals(1,0),equals(1,1))))
I think I've had to do something similar in the past and this was the solution I came up with. Would be keen to know if there are simpler ways as well.

Userlevel 5
Badge +14

it's always good to formulate a logic condition 'in words' before you start typing formula. then you have clear picture how overall formula should look like and do not get lost in single expressions

 

 

so in your case

show if => (Q9 or Q10 or Q11) is 'Yes'

which in 'correct' syntax should be: show if => (Q9 is 'Yes') or (Q10 is 'Yes') or (Q11 is 'Yes')

 

 

and which may be reversed as

hide if => not((Q9 is 'Yes') or (Q10 is 'Yes ) or (Q11 is 'Yes'))

or hide if => (Q9 is 'No') and (Q10 is 'No') and (Q11 is 'No')

or hide if => not(Q9 is 'Yes') and not(Q10 is 'Yes') and not(Q11 is 'Yes')

 

then it should be easy to select one of suitable formulas and rewrite it properly with nintex syntax

 

 

so yes, your the most recent formula version should be logically correct.

if you don't like its complexity you may chose one of the others

 

 

 

 

Badge +4

Hi all,

 

After I realised I need to state it in the 'positive' then invert it like @emha said, I realised the issue with the below is that I have an IF statement without an ELSE condition:

 

if(and(not(equals(Q9,'Yes')),and(not(equals(Q10,'Yes')),not(equals(Q11,'Yes'))))) 

 

once i got rid of the IF statement at the front, leaving the AND condition it worked. 

 

and(not(equals(Q9,'Yes')),and(not(equals(Q10,'Yes')),not(equals(Q11,'Yes'))))

 

thanks for all your help @emha @toms @jackgelo @fccrous 

Reply