cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Multiple validation rules

Jump to solution

Is it possible to set up multiple validation rules for a control without creating any custom validation? I want to create a validation that looks at 7 items and makes sure they are all unique numbers... so each control needs a "not equal to" the other 6 controls. It's not a problem when there's just one comparison, but I can't figure out how to add more than one.

Labels: (1)
0 Kudos
Reply
4 Replies
Workflow Hero

Re: Multiple validation rules

Jump to solution

I was really hoping there was a simple solution to this, but it's just not coming to me. Well, you can have 21 conditions in nested IFs, or i'm sure there is a way with reg expressions, but I found that I could do it with 7 rules with strings and not numbers.

  1. Create a validation rule for each control using the Contains runtime formula
  2. in the Contains formula make a concatenation of the controls like Contains(ctrl1+ctrl2+ctrl3,ctrl4)
  3. The element to test with should not be included in the first parameter as ctrl4 is not

nintextest.PNG

I tried this with numbers, but the issue was you have repeating numbers with 5 and 54 though they are not the same. I could not find another way of making a true collection of numbers even using calculation fields to help. But I wanted to share this in case it was any help at all.

You may be left with the many if statements, but hopefully not.

when i was looking at regular expressions I use the test (\d).*\1 which looks for the first repeat and returns the index. So a >0 would return true there is a repeat. But again, I could not make the series of numbers from the other controls together in one test.

I would think Javascript would be the easiest test for validation actually. Because you can create an array of the values, sort the array and test if the following value in the array is equal to the current value while looping through all values.

Or use the filter method on the array and compare the counts of an output array (haven't tested this)

var uniqueArray = duplicatesArray.filter(function(elem, pos) {

    return duplicatesArray.indexOf(elem) == pos;

  });

if (uniqueArray.count == duplicatesArray.count) {

     return true; // is valid

}

Reply
Not applicable

Re: Multiple validation rules

Jump to solution

What is the correct syntax for the nested IF statements, I have about 20 fields I need to use to validate against.

Dorinda

0 Kudos
Reply
Workflow Hero

Re: Multiple validation rules

Jump to solution

That may depend on what or how you need to compare the fields. But you could do 20 fields by:

A && B && C && D && E ...

you could use parenthesis if necessary too

A && B || (D && E) ...

You don't always have to use the IF runtime function unless you need the else statement.

Reply
Workflow Hero

Re: Multiple validation rules

Jump to solution

Nested if validation rule checking.

Formula Builder

and(contains(EVENTTYPE,"Recovery"),contains(BUSINESSFUNCTION,"Administration")) ||
and(contains(EVENTTYPE,"Recovery"),contains(BUSINESSFUNCTION,"Corporate finance")) ||
and(contains(EVENTTYPE,"Recovery"),contains(BUSINESSFUNCTION,"Trading and Sales - CM")) ||
and(contains(EVENTTYPE,"Recovery"),contains(BUSINESSFUNCTION,"Payments and settlements")) || and(contains(EVENTTYPE,"Recovery"),contains(BUSINESSFUNCTION,"Systems")) ||
and(contains(EVENTTYPE,"Recovery"),contains(BUSINESSFUNCTION,"Subscription")) ||
and(contains(EVENTTYPE,"Recovery"),contains(BUSINESSFUNCTION,"Outsourcing"))
Reply