cancel
Showing results for 
Search instead for 
Did you mean: 
flippomendes
Nintex Newbie

Issue With Logical Operators & Nested If Statement

Jump to solution

Hi folks,

    I'm having issues with my nested if statements. My conditional statement is shown in the image. I want my form to act this way;

  •    If any of the statements in the bracket following the "or" opeartor is true, then display message1
  •    If all the statements in the brackets following the "and" operator are true, display message 2.
  • else, display message 3

I think I may be applying the "or" statement incorrectly. This worked fine in my excel form. is it different with nintex?

Labels: (1)
0 Kudos
Reply
11 Replies
rhia
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

Hmm, seems right to me.

What current displays if you meet any of your OR conditions?

What displays if you meet NONE of your OR conditions but SOME of your AND conditions?

What's displaying if you don't meet ANY conditions?

Knowing what happens at present will help for sure! ...Probably!

Reply
flippomendes
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

Message 1 is being displayed when either of  the first 2 statements in the "or" bracket is true. It's ignoring the remaining statements. 

I m getting the desired outcome for both message 2 and 3.

0 Kudos
Reply
mmatsako
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

Sometimes its better to break a big problem into smaller parts and test.   In other words, test each rule part, piece by piece to make sure you are getting a "true" result and then keeping building your rule up from there.   May take more dev time with this approach, but a lot less on the troubleshooting side.

Reply
rhia
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

Are these variables attached to checkboxes or dropdowns or what?

0 Kudos
Reply
flippomendes
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

They are attached to check boxes.

0 Kudos
Reply
sojanm
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

Try using || and &&

If( ExtNoForDialExtensions1 == "No" || RestrictSetss =="Yes" || PickUp=="Yes" || AboveOne =="Yes" || Multical== "Yes" || DigitalTrans == "Yes", "Message 1" ,If( ExtNoForDialExtensions1 == "No" && RestrictSetss =="No" && PickUp=="No" && AboveOne =="No" && Multical== "No" && DigitalTrans == "No","Message 2") ,"Messge 3")

User the proper controls names in the above lines.

Reply
flippomendes
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

Thanks you all for your contributions!

I found that the issue with my nested if statement was that of hierarchy. I arranged the variables in the "or" logical operators in the order they appear in my form and it worked. 

Assuming the variables are A,B,C,D and E defined in ascending order in the form. Then my if Statements should be: 

If( A == "No" || B=="Yes" || C=="Yes" || D =="Yes" || E== "Yes" || F == "Yes", "Message 1" ,If( A == "No" && B =="No" && C=="No" && D=="No" && E= "No" && F == "No","Message 2") ,"Messge 3")

I also did some testing and the order of the variables doesn't affect the "AND" operator.

Thought I should share this for anyone who may have the same challenge I did.

Cheers!

Reply
emha
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

,

1. problem with your original formula was that you supplied too many arguments to or() and and() functions.

see their definition in help pages - they both can ONLY accept two arguments

http://help.nintex.com/en-US/nintex2013/help/#Forms/RootCategory/Designer/Nintex.Forms.RuntimeFuncti... 

so whatever you supplied as extra argument(s) was simply ignored.

2. have you really used a formula from your most recent post?

unlike your original post, this one is syntactically not correct, so can not (reliably) work.

3.

I arranged the variables in the "or" logical operators in the order they appear in my form and it worked. 

why do you think order/placement of controls on the form should/might have impact on formula evaluation?

would you expect that with every single control movement or when a control is added deleted, one would need to rewrite all the rules/calculation/etc just because of that?

since you turned to use javascript operators, it's all about the way of how javascript logical expression is evaluated, precedence of operators, what value are considered/convertable to true, etc.

if you can not spot the problem in evaluation, it's always the best approach to proceed from evaluation of simplest possible expression up to complex one(s), as Mike M‌ suggested above

Reply
flippomendes
Nintex Newbie

Re: Issue With Logical Operators & Nested If Statement

Jump to solution

1. I read the documentation before I even posted my question. No where in the document did it explicitly say that the "or" logical operator can only receive two arguments( aka I took the usage as an example). 

If( or (A == "No" , B=="Yes" , C=="Yes" , D =="Yes", E== "Yes" , F == "Yes"), "Message 1" ,If( and(A == "No",   B =="No", C=="No" , D=="No" , E= "No" , F == "No"),"Message 2" ,"Messge 3"))

works too. Only after arranging the variable in the order they appear in the form

2.  Yes, and it works! I used Sojan Mathew suggestion because Nintex won't accept the formula in my initial post. both formulas are syntactically correct.

3. I don't know why this is so in Nintex. I just shared my experience.

Cheers

0 Kudos
Reply