Please help me understand the logical difference between these two. # 2 works…# 1 doesnt.
@If(numconv>=2 & @Length (bn_1) = 3;@Success;@Failure(“Please enter a 3 digit bank number for your 2nd advance request. Click the back button to complete the form”))
@If(numconv>=1 & (!@Length (bn) = 3);@Failure(“Please enter a 3 digit bank number for your 1st advance request. Click the back button to complete the form”);@Success)
Subject: Whats the difference between these 2 validations?
What’s numconv? Are bn and bn_1 number or text fields?
Subject: Its the ! placement Try: @If(numconv>=1 & (@Length(bn) != 3);@Failure…
Subject: Whats the difference between these 2 validations?
Be careful with the ! operator. If you mean to measure whether the length of bn is not equal 3 then you’d be better using @Length(bn) != 3 or even !(@Length(bn) = 3)
The expression !@Length(bn) gets evaluated first and that will return a zero if the string is not empty. Therefore you are really saying if 0 = 3 which of course will always be false.
The rule with operator precedence is always to use brackets to make your meaning clear to the comiler AND to humans who will read the code !
Hope this helps.
Subject: RE: Whats the difference between these 2 validations?
Sorry, bn & bn_1 are text fields and numcov is a number field.
Thanks for you guys help. I still dont get why this doesnt work…
@If(numconv>=2 & @Length (cn_1) = 7;@Success;@Failure(“Please enter a 7 digit customer number for your 2nd advance request. Click the back button to complete the form”))
The validation fires when numconv is = 1 or 0. If numconv is less than 2, shouldn’t it evaluate this (numconv>=2) and stop at that point?
Subject: RE: Whats the difference between these 2 validations?
Surely that’s right! If numconv is more than or equal to 2 then it will pass otherwise it will fail
Subject: RE: Whats the difference between these 2 validations?
No – Boolean evaluations don’t short-circuit in Formula Language, so “@Length(cn_1) = 7” will evaluate.