FunctionCopy link to clipboard
displayvalue( value, inArray, replacement, default )
Tries to match a value in a given array with a value at the same index in a replacement array and returns either the value at the same index or a default value if the value is not found.
See also: resource()
ParametersCopy link to clipboard
Keyword | Type | Description |
---|---|---|
|
Any Type |
The value to search for in the array. Will cast to the type of inArray. |
|
Any Type Array |
The array to be searched. |
|
Any Type Array |
The array of replacement values. |
|
Any Type |
The default value to be returned if the search value is not found. |
ReturnsCopy link to clipboard
Any Type
Usage considerationsCopy link to clipboard
Suggested usesCopy link to clipboard
This function is typically used to return a text display value that corresponds to an ID value stored in a process variable and makes it easier to generate reports that show human-readable values instead of numeric IDs in process data.
You can also use it to search a CDT array and return the CDT that has a field value matching a process variable value. Do this by creating an expression similar to the following: displayvalue(pv!departmentID, pv!departments.departmentID, pv!departments, "none")
Using the value parameterCopy link to clipboard
The type of the argument passed to value must match the types in the replacement array, otherwise the default value will be returned.
Using the replacement parameterCopy link to clipboard
If the length of the replacement array is shorter than the inArray array, the replacement array will be repeatedly extended until it is the same length as the longer inArray array.
Using displayvalue() with arraysCopy link to clipboard
This function supports expressions or process variables for arrays.
ExamplesCopy link to clipboard
Return a priority level based on the number in an arrayCopy link to clipboard
1
2
3
4
5
6
7
8
9
a!localVariables(
local!priority: 2,
displayvalue(
local!priority,
{0,1,2},
{"Low","Medium","High"},
"Unknown"
)
)
Copy
Returns High
. If you change local!priority
to 3
, the expression returns Unknown
.
Working with string valuesCopy link to clipboard
1
2
3
4
5
6
displayvalue(
{ "Group 1" },
{ "Group 1", "Group 2", "Group 3", "Group 4" },
{ "Order", "Customer", "Invoice", "Parts" },
"Unknown Group"
)
Copy
Returns "Order"
.
Working with integer valuesCopy link to clipboard
1
2
3
4
5
6
displayvalue(
{ 3 },
{ 1, 2, 3, 4, 5 },
{ "A", 2, "C", "D", 5 },
"Unknown"
)
Copy
Returns "C"
.
Working with boolean valuesCopy link to clipboard
1
2
3
4
5
6
displayvalue(
{ true },
{ true, false },
{ "First", "Second" },
"Unknown"
)
Copy
Returns "First"
.
Return a value not found in replacementCopy link to clipboard
1
2
3
4
5
6
displayvalue(
{ "Group 4" },
{ "Group 1", "Group 2", "Group 3", "Group 4" },
{ "Order", "Customer", "Invoice" },
"Unknown Group"
)
Copy
Returns "Order"
. If the matching index from inArray is not found in replacement, then the the index loops back to beginning of the list. In this case, the first value from replacement is returned.
Use with the resource()
function to display internationalized textCopy link to clipboard
In the custom_locale_en_US.properties
file located in the <INSTALL_HOME>/server/_conf
directory, define the following key value pairs:
- low=Low
- medium=Medium
- high=High
Define a pv!priority
process variable of type Number and set the current locale to en_US
.
1
2
3
4
5
6
displayvalue(
pv!priority,
{0,1,2},
{resource("low"),resource("medium"),resource("high")},
"Unknown"
)
Copy
Returns High
when pv!priority = 2
because the resource() function looked up the value for the key high
.
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 |