FunctionCopy link to clipboard
or( value )
Returns true
if any inputs are true
; returns false
if all inputs are false
.
See also:
- and(): Similar to
or()
, but instead returnstrue
if all of the input values returntrue
. - any(): Calls a rule or function for a list of values to determine if any the results return
true
. This function is a combination of a!forEach() andor()
.
ParametersCopy link to clipboard
Keyword | Type | Description |
---|---|---|
|
Boolean |
A value or array of values that must be false for the function return false. |
ReturnsCopy link to clipboard
Boolean
Usage considerationsCopy link to clipboard
Casting and returning boolean valuesCopy link to clipboard
- Arguments are cast to Boolean before
or()
evaluates. - If a value cannot be cast to a Boolean, the function returns an error.
Evaluation order and performanceCopy link to clipboard
- Arguments are evaluated in order from left to right.
- As soon as any value evaluation returns
true
, the function returnstrue
. All values must evaluate tofalse
for the function to returnfalse
. - By keeping common conditions on the left and complex edge cases on the right, you can improve function performance. That way, if an earlier, simple function returns
true
, evaluation of the later edge cases never occurs. - Runtime errors on arguments that are not evaluated will not result in an error in the evaluation of the
or()
function. During troubleshooting, try evaluating each expression independently to identify issues.
Null and empty arraysCopy link to clipboard
- Null values that are part of input arrays are filtered out before evaluation.
- Empty dictionaries, maps, CDTs, or records evaluate to
false
. - Empty text strings in a text array evaluate to
true
, but empty text strings in an array with multiple data types are considered null values and are filtered out before evaluation.
Using listsCopy link to clipboard
- Values can be provided either as separate arguments or within a list. For example, the following are both valid and will return the same result:
or(true, true, false)
or({true, true, false})
- If multiple lists are provided, the items are flattened into a single list before evaluating each item.
Tip: The or()
function is useful within a component's showWhen parameter. This allows you to display the component if any of the conditions return true
.
ExamplesCopy link to clipboard
Basic examplesCopy link to clipboard
Pass an empty arrayCopy link to clipboard
or({})
returns false
Pass an array of numbersCopy link to clipboard
or(1,2,"",3)
returns true
or(0,1,2,"",3)
returns true
Applying multiple conditions to a single valueCopy link to clipboard
1
2
3
4
5
6
7
a!localVariables(
local!date: date(2022, 1, 2),
or(
calisworkday(local!date),
local!date > today()
)
)
Copy
This returns false
because 2 Jan 2022 is a date in the past and it is not a work day in the default calendar.
Conditionally showing or hiding componentsCopy link to clipboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
a!localVariables(
local!selection,
local!description,
{
a!radioButtonField(
label: "Approved",
choiceLabels: {"Yes", "No"},
choiceValues: {"Yes", "No"},
value: local!selection,
saveInto: local!selection
),
a!paragraphField(
label: "Comments",
value: local!description,
saveInto: local!description,
showWhen: or(
a!isUserMemberOfGroup(
username: loggedInUser(),
groups: cons!MY_GROUP_SUPERVISOR
),
local!selection = "No"
)
)
}
)
Copy
The paragraph field is only displayed if the user is in the supervisors group or they have selected No
in the radio button selection.
Checking the results of an integrationCopy link to clipboard
1
2
3
4
5
6
7
8
9
10
11
12
a!localVariables(
local!response: rule!MY_IntegrationRule(),
if(
or(
a!isNullOrEmpty(local!response),
local!response.success = false,
local!response.result.body.totalCount = 0
),
"Error Occurred",
"Total Results: " & local!response.result.body.totalCount
)
)
Copy
In this example, the results of an integration are stored in local!response
. We'd like to return the total number of results, but there are several possible error scenarios. If any of the following occur, we should provide a generic error message:
- The result is null or empty.
- The success parameter returns
false
, which often occurs when an integration returns a 500 or 404 error. - The total number of results is 0.
Feature compatibilityCopy link to clipboard
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 | |
Process Autoscaling | Compatible |