cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

If statement with && in the first argument

Jump to solution

I have a calculated value control. For its formula, I want to evaluate a couple values on the form. For the the logical_test argument (first part of If statement), I have tried the following, and  I can't quite get the syntax. Ideas?

(I am looking for payment option of "Description A" and a payment amount between 5 and 10. String1 and String2 are the options for the calculated value to display.)

If(logical_test, value_if_true, value_if_false)

If(PaymentOption == "Description A" && PaymentAmt > 4.99 && PaymentAmt < 10,"String1","String2")

If((PaymentOption == "Description A" && PaymentAmt > 4.99 && PaymentAmt < 10),"String1","String2")

If((PaymentOption == "Description A") && (PaymentAmt > 4.99) && (PaymentAmt < 10),"String1","String2")

I can get it to work with any combo of two items in the logical_test argument. It's the third one that is throwing things off. 

Tags (2)
Reply
8 Replies
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

Hi Mindy‌,

Are the used field references the Named Control names or the Item Properties? You should always name your form controls and use those and NOT the item properties. 

Also, what is the type of PaymentOption? If it's a list lookup, then you might parselookup the value: parselookup(PatmentOption)=="Description A"

Have you tried:

  1. each individual criterion?
  2. used the function equivalents of ==, < and >: equals(), lessthan(), greaterthan()?

Btw: I would always go for grouping criterias as in your 3 option: If(() && () && (), "....", "....")

Reply
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

Yes I am using the Named Control names (not Item Properties) when building the formula.

PaymentOption is a choice field.

I have tried each individual criterion to see if I just have the syntax wrong or the name of the control wrong or something like that, but each piece checks out OK.

FUNCTION EQUIVALENTS!! Let me try that. Stay tuned...

0 Kudos
Reply
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

YES to the function equivalents!! Thank you, !!

Here is what worked for me: 

If((greaterThanOrEqual(PaymentAmt,5)) && (lessThan(PaymentAmt,10)) && (equals(PaymentOption,"yada yada.")),"yes","no") 

0 Kudos
Reply
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

Well one more question, Jean-Pierre Huls‌ ... I actually have two of these busters to hook together. It executes the first IF but doesn't seem to do anything with the second. I can switch the two pieces around and get the same result (the first piece works but after the || doesn't). Ideas?

If((equals(PaymentOption,"yada yada"))&& (greaterThanOrEqual(PaymentAmt,5)) && (lessThan(PaymentAmt,10)),"Inc2","NO Inc2") || If((equals(PaymentOption,"blah blah")) && (greaterThanOrEqual(PaymentAmt,5)) && (lessThan(PaymentAmt,10)),"Inc2","NO Inc2")


(If((equals(PaymentOption,"yada yada"))&& (greaterThanOrEqual(PaymentAmt,5)) && (lessThan(PaymentAmt,10)),"Inc2","NO Inc2")) || (If((equals(PaymentOption,"blah blah")) && (greaterThanOrEqual(PaymentAmt,5)) && (lessThan(PaymentAmt,10)),"Inc2","NO Inc2"))

0 Kudos
Reply
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

FYI: The initial if criteria you posted seem to work for me (NF 2013 v2.11.2.2) both with and without brackets around each criterion........

Reply
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

Hi Mindy‌, now your test reads: If(BusterCheck1 || If(BusterCheck2),"Inc2","NO Inc2")) which makes no sence. So get rid of the 2nd If (wording only) but leave tests inside its brackets: If((BusterCheck1) || (BusterCheck2),"Inc2","NO Inc2").

Reply
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

I got all turned around didn't I. Thank you, ‌ !!

Reply
Workflow Hero

Re: If statement with && in the first argument

Jump to solution

Don't worry, this happens to the best of us .

0 Kudos
Reply