Solved

Nintex Forms Rule - Proper Formula syntax

  • 20 April 2021
  • 4 replies
  • 557 views

I'm trying to get the syntax for a rule formula correct and I must be doing something incorrectly because, well, it doesn't do what I want it to do. 

 

I have a field with 7 radio buttons, I'll call them A, B, C, D, E, F and G.  I also have a panel with a couple fields in it that I want to have displayed on the form, but only if options B, C, or D are selected.  The field name associated with the 7 options is called WorkflowState.  I've been trying to use the "Or" statement but it doesn't seem to work.  My statement is below.

 

 WorkflowState!='B'||WorkflowState!='C'||WorkflowState!='D'          Hide the panel if rule runs

 

I've tried spaces on both sides of the || characters but nothing seems to work.  If I just do a single value without any ||, it works fine.

 

Any assistance would be appreciated.

icon

Best answer by MegaJerk 21 April 2021, 17:53

View original

4 replies

Userlevel 6
Badge +16

Perhaps you are incorrectly using item properties instead of Named Controls

Thanks for the response. No, I'm using Named Controls for them. When I used Item Properties, they would get returned as {ItemProperty:WorkflowState} which didn't work.
Userlevel 5
Badge +14

The Or Statement will continue to evaluate statements until it reaches one that is true.


 


Rules are "executed" when the value returned to them is true.


So what's happening?


Let's say you've set your WorkflowState to "C".


 


Your code is going to first evalute:


WorkflowState !== "B"

 


which, when translated into human speak is, "WorkflowState does NOT equal B", which is true!


 


Because you've reached a truthy value, the Or evaluation stops, and returns true, which triggers the rule, which hides your panel... which is not what you want.


 


What you actually want to happen is some sort of exclusive condition, which means that you'll need to use AND (&&) instead of OR (||).


 


AND, unlike OR, will ONLY return true if ALL of the statements are true. Remember, we only wanna return true when we want the panel hidden!


 


Consider the following:


WorkflowState !== "B" && WorkflowState !== "C" && WorkflowState !== "D"

 


Now, let's see what happens when you've set the WorkflowState to "C".


 


First the code evaluates: WorkflowState !== "B"


 


Well... that's true! It doesn't equal "B"! It equals "C"!


 


onto the next.


 


WorkflowState !== "C"


 


This is false! It *does* equal "C", and because we've now reached a false value, the rest of the AND chain no longer needs to be evaluated and this will return false. Because it's returning false, the rule will NOT hide the panel.


 


I hope this helps to clear things up. 


 

Like the user name...!

This solved the issue perfectly. My form now displays what I need it to display, when it's supposed to display it. Thanks much for the great explanation, it really helped...!!!

Reply