Free cookie consent management tool by TermsFeed if() Function
if() Function

Function

if( condition, valueIfTrue, valueIfFalse )

Returns valueIfTrue if condition returns true; returns valueIfFalse otherwise.

See also: a!match()

Parameters

Keyword Type Description

condition

Boolean

A test that determines whether valueIfTrue or valueIfFalse will be returned.

valueIfTrue

Any Type

The value to be returned if condition returns true.

valueIfFalse

Any Type

The value to be returned if condition returns false.

Returns

Any Type

Usage considerations

Evaluation order

  • Unlike most functions, if() does not always evaluate all of its parameters. When passed a single condition, the function evaluates the condition and then only the value parameter that is returned.

Null and empty values

  • When null values are passed to the condition parameter, they are considered to be false.
  • When a list is passed to the condition parameter, it is treated as a list of conditions and the value parameters will be treated as lists of values to return.
    • This means that when passed an empty list, if() always returns an empty list.
    • When passed a list containing a single boolean and lists in the value parameters, only the first item of the selected list will be returned.

Examples

if(isleapyear(1996), 1, 0) returns 1

if(isleapyear(1997), 1, 0) returns 0

if(null, 1, 0) returns 0

if(true, 1, error("Doesn't get evaluated")) returns 1 (because the parameter with error() does not get evaluated)

if(true, { 2, 4, 6 }, { 1, 3, 5 }) returns { 2, 4, 6 }

if({true, false, true}, { 2, 4, 6 }, { 1, 3, 5 }) returns { 2, 3, 6 }

if({true}, { 2, 4, 6 }, { 1, 3, 5 }) returns { 2 }

if({}, { 2, 4, 6}, { 1, 3, 5 }) returns {}

See also

a!defaultValue: Consider using the a!defaultValue function when you are replacing a null value with another value or have nested if and isnull statements.

Feature compatibility

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Compatible
Offline Mobile Compatible
Sync-Time Custom Record Fields Compatible

Can be used to create a custom record field that only evaluates at sync time.

Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Compatible
Process Events Compatible
Open in Github Built: Fri, Apr 12, 2024 (09:32:43 PM)

if() Function

FEEDBACK