Validate Multi-Select Choice Field


Badge +7

Hi!

I'm trying to figure out the correct syntax to validate my multi-select choice field. We want the users to check all the fields that apply:

  • The account was reviewed
  • Account has sufficient funds
  • Account has insufficient funds
  • Agreement on file
  • Agreement not on file

The process will continue based on any combination of choices. However, the only combination that would not be valid would be if the account had both sufficient and insufficient funds. I need a rule that will invalidate this field if "Account has sufficient funds" and "Account has insufficient funds" are both selected. I tried this:

contains(Choice, "Account has sufficient funds") && contains(Choice, "Account has insufficient funds")

and this:

equals(Choice, "Account has sufficient funds") && equals(Choice, "Account has insufficient funds")

but those don't work. I also tried fiddling around with an array, but I'm not very familiar with that and haven't been successful:

!inArray(Choice, "Account has sufficient funds") && inArray(Choice, "Account has insufficient funds")

I feel like I'm close, it seems like these should work. Can I get some guidance?


12 replies

Userlevel 5
Badge +13

Hi Andrea,

Try using the formula below in your validation rule. It worked for me in Nintex Forms 2013. Make sure you use the Named Control in place of "Choice".

and(contains(Choice, "Account has sufficient funds"), contains(Choice, "Account has insufficient funds"))

Userlevel 5
Badge +14

in your formula with inArray(), remove exclamation mark at the very beginning.

you want to invalidate control when both options are selected, ie. when both inArray() checks are true.

Badge +7

I see the mistake I made when writing both of the formulas. I changed them and tried both, but neither works:

and(contains(AccountReviewforConstraints, "Account has sufficient funds"), contains(AccountReviewforConstraints, "Account has insufficient funds"))

and:

and(inArray(AccountReviewforConstraints, "Account has sufficient funds"), inArray(contains(AccountReviewforConstraints, "Account has insufficient funds"))

I applied a simple validation rule that the field is invalid if isNullorEmpty({Self}) and it works, so there doesn't seem to be a problem with the field. The validation data type is set to "string", so I'm not sure why either formula isn't working.

Userlevel 5
Badge +14

I guess mix of InArray() and contains() is just a typo not your real formula...

if the formula with InArray() doesn't work for you, check the spelling. it should evaluate to true if you select both options

214430_pastedImage_4.png

214431_pastedImage_5.png

Userlevel 5
Badge +13

Here's a screen shot of the validation rule configuration:

Nintex Forms - Multiselect choice column validation 2

Here's a screen shot of the form with the validation rule:

Nintex Forms - Multiselect choice column validation 1

Badge +6

Good Morning,

I did a little test and found the following works:

This is my test Form with the Choice fields, on the right hand side i used a calculated value control to display what the data in the choice field looks like:

214448_pastedImage_1.png

I then constructed my Validation rule like this:

214449_pastedImage_2.png

Userlevel 5
Badge +14

this is not proper/reliable approach!

if you needed to check for both choice 1 & 3 are checked, and choice 2 would be checked as well your validation wouldn't work.

Badge +6

Using what I found in my Previous reply and Considering Marian Hatala‌'s response I changed my validation rule to the following:

214451_pastedImage_3.png

Formula Builder
contains(ChoiceField, 'Choice 1')&&contains(ChoiceField, 'Choice 2')
This way it invalidates if your selections contain both "Choice 1" AND "Choice 2"
Badge +7

Is there a character limit in the string? I've done this formula over and over, 4 or 5 times following everyone's suggestions, and it simply doesn't work. The actual selections in the field say this:

Accessible balance sufficient to wire funds: attach DE00 screen print, WIP ticket/offset copies, CLLO/CLW monetary request eform, etc.

Accessible balance not sufficient and Daylight OD Form completed and approved: attach DE00 screen print

Is this too much text or something? I'm using Nintex 2016. I have run into issues with Nintex 2013 with too many rules in a form and I have a lot of rules in this thing. Could that be part of the issue also?

Here is my actual formula:

contains(AccountReviewforConstraints, 'Accessible balance sufficient to wire funds: attach DE00 screen print, WIP ticket/offset copies, CLLO/CLW monetary request eform, etc.') && contains(AccountReviewforConstraints, 'Accessible balance not sufficient and Daylight OD Form completed and approved: attach DE00 screen print')

This looks good to me. This looks like it should work and it doesn't. I've tried single quotes and double quotes. I've tried "&&" and "and()" and nothing works. Is it possible there are too many characters in the string? I am going to fiddle around with it and see what happens.

Userlevel 5
Badge +13

I changed my choice list column to your values and updated the rule formula. The rule in the form still worked fine for me and caused the field to be invalid.  I'm using Nintex Forms 2013.  My control name is "Funds" instead of yours which is "AccountReviewforConstraints".  Here's the updated formula I used in the validation rule on the control:

and(contains(Funds, "Accessible balance sufficient"), contains(Funds, "Accessible balance not sufficient"))

Try shortening the parameters in your formula so they're like mine to see if that makes a difference.  Also make sure the validation rule is on the AccountReviewforConstraints control.

Userlevel 5
Badge +14

text length shouldn't be a problem.

but you have within the text commas and slashes which may confuse parser. try to use {TextStart} and {TextEnd} tokens instead of quotes.

Badge +7

GOT IT!!

The right answer was a combination of input from everyone's suggestions and a LOT of trial and error.

  1. I renamed the control to match the new column name
  2. I shortened the values in my selections
  3. I used inArray

Now it works the way it should. Good grief, it shouldn't be this hard!

inArray(AccountReview, "Accessible balance sufficient") && inArray(AccountReview, "Accessible balance not sufficient")

Reply