if( condition, valueIfTrue, valueIfFalse )
Returns valueIfTrue
if condition
returns true
; returns valueIfFalse
otherwise.
See also: a!match()
Keyword | Type | Description |
---|---|---|
|
Boolean |
A test that determines whether valueIfTrue or valueIfFalse will be returned. |
|
Any Type |
The value to be returned if condition returns true. |
|
Any Type |
The value to be returned if condition returns false. |
Any Type
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.if()
always returns an empty list.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 {}
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 | 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 | |
Process Reports | Compatible | |
Process Events | Compatible |
if() Function