Solved

Forms Rules issue using && and ||


Badge +3

I have a form on which I want to show a particular control if one of two conditions is met (based on selections from other drop downs).  I have done this (on the very same form) several times for different controls using just one condition, and it works.  But something about the || operator seems to be giving me grief with this particular rule.  

 

Basically if the user makes a specific selection in the 'Type' drop down ("A"), then in the 'Owner' drop down selects one of two options ("ZZ" or "YY"), the field would appear.  Both drop downs of course have other options, any combination of which would leave the field hidden.   So conceptually, the rule should be along the lines of:

When:

Type != "A" && (Owner != "ZZ" || Owner != "YY")

Then:

Hide

 

For some reason, it works when Type A is selected alongside Owner YY, but not when ZZ is selected.  I have tried moving the brackets around, and even writing out using the actual 'and', 'not' 'equals' terms along with all the appropriate brackets...  but no matter what, it doesn't work as expected.  I feel like i am missing something simple.

 

icon

Best answer by Garrett 3 June 2022, 11:15

View original

6 replies

Userlevel 6
Badge +16

Hi @slarsson 


 


Here is my solution.


 


Sample Form.
2 Dropdowns - ChoiceType, ChoiceOwner
1 Text Field - TextField1 (Default Set to Hide or Visible is NO)




 


when Type == A && Owner == ZZ or


when Type == A && Owner == YY


THEN Show


ELSE Hide



 


 


 


 


 

Badge +3

Thanks @Garrett 


My problem is I can't find that rule builder interface.  Wondering I have an older version or something?  


 


Mine looks like this:



 


And i have to click the formula button to open up:


 



 


 

Userlevel 6
Badge +16

@slarsson 


 


I'm using the New Responsive designer



 

Userlevel 6
Badge +16

@slarsson 


 


I got it working!! 


I tested with the Responsive Form. 


ChoiceType, ChoiceOwner and TextField1




 


Results:



 


Type != "A" && (Owner != "ZZ" || Owner != "YY")   Rule is not working!!


Tried your formula... Its not working as it should. When only A is selected, the TextField is visible


 


Solution:


!(Type == "A" && (Owner == "ZZ" || Owner == "YY"))


I change all the != (Not equals) to == (equals to)


I surround the entire formula in parenthesis and


I put a ! (Not)  in front of the formula



 


Hope this helps you!


 

Badge +3

Genius @Garrett!


You make it seem to simple, but it would have taken me months to figure that out!  Thank you very much!     It works perfectly now!

Userlevel 6
Badge +16

Great @slarsson!


 


You're welcome!


If its not too much, I would appreciate a Kudos too 😉 😉


 

Reply