orbeon

IF Statement with an AND Operator


Hopefully this is a simple one..

Is it possible to have an "IF" statement with an "AND operator on a calculated value box:

enter image description here

I've tried various options without any luck, for example:

IF (AND ($Field1/string() = 'Completed'), ($Field2/string() = '')) then 'OK' else.

IF (AND ($Field1/string() = 'Completed', $Field2/string() = '') then 'OK' else.

if ($Field1/string() = '' and $Field2/string() = 'Completed') then 'true' else .

Also, can you use variables in these boxes (e.g. Var myFieldA)

Many thanks in advance.

PeteA


Solution

  • Your third exception expression looks correct:

    if ($Field1/string() = '' and $Field2/string() = 'Completed')
    then 'true' else .
    

    The if must be in lowercase. Also and is an infix operator, as is the case in most languages, i.e. it isn't used as a function. Yes, you can access the value of other fields through variables, using the $ syntax, but make sure that those names are correctly capitalized, as $field is different from $Field.