Hi All,
Please help in understanding or explaining the working of the following code.
displayvalue( 5, { 1, 2, 3, 4, 5 }, { "A", "B", "C", "D" }, "Z")
In the above sample code, based on it's behavior, ideally, the result should be the default value ("Z" in this case as there is no item in 5th index of 2nd array). But the result I'm getting is "A", the 1st index from the array.
Version I'm using is Appian 24.4
Please refer the screenshot attached.
Discussion posts and replies are publicly visible
The displayvalue() function loops the replacement array when it's shorter. Since your replacement array {"A","B","C","D"} has only 4 items but you're looking for position 5, it wraps around to position 1 and returns "A". The default value "Z" is only used when the search value doesn't exist in the input array at all (like searching for 6 instead of 5). This is expected behavior.