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

How to use If Then statements in form validation rules.

I have a clothing order form that I want to use form validation rules on. Some shirt styles are only available in certain colors. "ShirtStyle" is my control name, my goal is that if you choose a shirt style you are only able to select certain colors. If you choose a color not in the validation rule for that style you will get an error that tells you this shirt is not avalaibel in this color. Below is my rule but it does not seem to work but I am not sure what I have wrong. I have 6 shirt styles but I only started with 2 styles to get started. 

if ShirtStyle =="Instructor" then
not(equals("Red", "Hi-Viz Yellow")) || if ShirtStyle =="Basic" then
not(equals("Black", "Red", "Green", "Gray", "Charcoal"))
Labels: (1)
Tags (1)
0 Kudos
Reply
4 Replies
Highlighted
Nintex Employee
Nintex Employee

Re: How to use If Then statements in form validation rules.

Does something like this work for you:

If(ShirtStyle == "Instructor" && (Color != "Red" || Color != Hi-Viz Yellow"),true,false) || If(ShirtStyle == "Basic" && (Color != "Black" || Color != "Red" || Color != "Green" || Color != "Gray" || Color != "Charcoal"),true,false)

 

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: How to use If Then statements in form validation rules.

When I modify @ example like this:

if(ShirtStyle == "Instructor" && ({Self}!="Red" || {Self}!="Hi-Viz-Yellow"),true,false) 

it fails to validate anything they all fail. 

When I modify it to this:

if((ShirtStyle == "Instructor" && ({Self} != "Red")) || if(ShirtStyle == "Instructor" && ({Self} !="Hi-Viz-Yellow")),true,false)

The first validation for for picking the color "Red" works but if I choose "Hi-Viz-Yellow" it fails to validate, if i switch the colors around the first one will work but the second fails.

What do I need to change to get this to move past the first rule? I will have to add many other lines of vailidation to this as I have 5 shirt styles. 

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: How to use If Then statements in form validation rules.

Update to my problem, I have figured out how to get the first 2 to validate but when I add a 3rd validation rule it no longer works and I am not sure why. Below is what works: 

If(ShirtStyle == "Instructor" && (Color != "Red"),
If(ShirtStyle == "Instructor" && (Color != "Hi-Viz-Yellow"),
true,false))
This will fail the validation if any other color besides "Red" and "Hi-Viz-Yellow" are chosen when the shirt style is "Instructor". If I add another shirt style to the validation rule then it no longer works that rule is below.
 
If(ShirtStyle == "Instructor" && (Color != "Red"),
If(ShirtStyle == "Instructor" && (Color != "Hi-Viz-Yellow"),
If(ShirtStyle == "Class C" && (Color != "Tan"),
true,false)))
This does not work for either Shirt Style. Will the approach that I am taking just not work for this? I intend to have it look something like below unless this just does not work.
If(ShirtStyle == "Instructor" && (Color != "Red"),
If(ShirtStyle == "Instructor" && (Color != "Hi-Viz-Yellow"),
If(ShirtStyle == "Class C" && (Color != "Tan"),
If(ShirtStyle == "SRO" && (Color != "Black"),
If(ShirtStyle == "Basic" && (Color != "Green"),
If(ShirtStyle == "Basic" && (Color != "Gray"),
If(ShirtStyle == "Basic" && (Color != "Charcoal"),
If(ShirtStyle == "Basic" && (Color != "Maroon"),
true,false))))))))
 
 
 
0 Kudos
Reply
Highlighted
Nintex Employee
Nintex Employee

Re: How to use If Then statements in form validation rules.

Instead of using If() runtime function just use:
(ShirtStyle == "Instructor" && (Color != "Red" || Color != Hi-Viz Yellow")) || (ShirtStyle == "Basic" && (Color != "Black" || Color != "Red" || Color != "Green" || Color != "Gray" || Color != "Charcoal"))
0 Kudos
Reply