if

The if function is used for conditional mappings.

Syntax

c4i:if(condition, then [, else])

Parameters

condition

The condition to evaluate.

It can be :

  • A boolean value
  • A number value. The value 0 will evaluate to false
  • A list of elements from a xPath. Empty lists will evaluate to false

then

The value to return if the condition evaluates to true

else (optional)

The value to return if the condition evaluates to false. null by default

Return value

The supplied "then" parameter if the condition evaluates to true, otherwise the supplied "else" parameter if supplied, null otherwise.

Remember to use bool, number or json custom functions to force the result output type if necessary. Otherwise, the return type will always be text.

Last Updated: