comparing var in conditional statements

Not applicable

I have to place a condition in flow to only execute a policy only if a variable(which will have json payload) has no value. Currently I am using following conditions;

1)<Condition> ((var == null) or (var == "") ) </Condition> //evaluate to false or true based on var value

2) <Condition> (var == false) </Condition> // always evaluate to true regardless of value of var so act as assignment operator

3) <Condition>( !var) </Condition> // doesn't work, not valid

Is there any other shorter way than first statement to give specify this condition ?

0 4 892
4 REPLIES 4

Hi @raul ,

Please check same question Unary operator in conditional flows

Thanks for reference but it's not working as expected;

1)

<Condition> (var != true) </Condition> 
<!-- always evaluates to true regardless, if there is Json payload in var or nothing -->

2)

<Condition> (var == false) </Condition>
<!-- always evaluates to true regardless of value of var so act as assignment operator -->

I tried it with both

Var has json payload

Var is empty string, no json payload

I am placing this condition on service callout policy, var is populated in previous policies. Not sure why it is not working.

I know this is an old question and surely you've moved on.

But if anyone else experiences this issue, There is something else going on. Condition statements in Apigee Edge actually work as documented. If your var is false, both (var != true) and (var == false) will resolve to true. If your var holds anything other than false, (var == false) will evaluate to false.

Re-consider your assumptions. Are you sure that var holds what you think it holds? Is it a string or a boolean? Are you sure your conditions are being evaluated at all?

Hi @raul,


Usually in APIGEE != is not working as expected in conditional statement but you can use following statement for your 3 statement

<Condition> !(var == null or var == "") </Condition>