displayvalue() Function

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.

Syntax

displayvalue( value, inArray, replacement, default )

value: (Any Type) The value to search for in the array. Will cast to the type of inArray.

inArray: (Any Type Array) The array to be searched.

replacement: (Any Type Array) The array of replacement values.

default: (Any Type) The default value to be returned if the search value is not found.

Returns

Any Type

Notes

This function supports expressions or process variables for arrays.

It 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")

The type of the argument passed to value must match the types in the replacement array, otherwise the default value will be returned.

Examples

Return a Priority Level Based on the Number in an Array:

displayvalue(!priority,{0,1,2},{"Low","Medium","High"},"Unknown") returns High when !priority=2 and Unknown when !priority=3

Use with the resource() Function to Display Internationalized Text:

In the custom_locale_en_US.properties file located in the <INSTALL_HOME>/server/_conf directory, define the following key value pairs:

1
2
3
low=Low
medium=Medium
high=High

Define a !priority process variable of type Number and set the current locale to en_US.

displayvalue(!priority,{0,1,2},{resource("low"),resource("medium"),resource("high")},"Unknown") returns High when !priority=2 because the resource() function looked up the value corresponding to the key high.

See Also

resource(): Use this function to look up key values when using displayvalue() for the internationalization of display values in place of literal values for the replacement parameter.

Open in Github Built: Fri, Nov 04, 2022 (07:10:52 PM)

On This Page

FEEDBACK