validation only evaluating part of expression

  • 6 December 2016
  • 4 replies
  • 2 views

Badge +6

I have a custom validation that is only evaluating part of the expression. It's attached to a choice control (dropdown) 

If I chose 

And a value from the second dropdown

The validation will be successful

If I chose 

And a value from the second dropdown, the control will fail the validation regardless if a value is selected or not


4 replies

Userlevel 5
Badge +14

1. javascript's '&&' operator has higher precedence over '||'.

so, 2nd and 3rd expressions are first ANDed and result then ORed with1st expression in your formula.

I feel you wanted first OR to be evaluated and then result ANDed to 3rd expression.

2. to check for control emptiness use rather isNullOrEmpty() runtime function

Badge +6

Hi Marian,

I have tried the following with the same results

And

Userlevel 5
Badge +14

you have reordered single expressions but you haven't changed evaluation logic at all.

your formula should look like (simplified)

isNullOrEmpty(SSMP) && (MEO == 'Family' || MEO == 'Adult')

note parentheses there to force OR evaluate before AND.

from logic point of view it doesn't matter whether you put && before or after parentheses.

Badge +6

this resolved the issue

is there a reference for the order of rules and logic?

Reply