Designers > K2 Designer for Visual Studio > Design Tools > Inline Functions > Function Browser > Lists | Send feedback |
List functions perform calculations on lists based on input values and returns a number.
Fig. 1. Lists
An item is selected and then added to the canvas or K2 field part by clicking the Add button or by using drag-and-drop.
Functions | Description | Example |
---|---|---|
Count |
Counts the number of items in a list of values. Values - Input Integer - Return type |
Input Values: { 1, 2, 3 } Result: 3 |
First Item |
Gets the first value in a list. Values - Input Expected When Empty - Object type. This is returned when the input value is invalid Object - Return Value |
Values: {1, 2, 3} Expected When Empty: 0 Result: 1 |
Index Item |
Gets the last value in a list. Values - Object of array type. e.g. output from a Split() function call can be passed into this parameter. When using an XML node, make sure to use the lowest node in the tree. Index - Number of long type. This specifies the 1-based index of the item in the array you wish to retrieve. Expected When Empty - Object type. This is returned when the input value is invalid or when the index specified is out of bounds. Object - Return value (Object) is the selected object in the array if there are no errors. |
Example 1: Values: { "a", "b", "c" } Index: 1 Expected When Empty: "empty" Result: "a" Example 2: Values: { "a", "b", "c" } Index: 4 Expected When Empty: "empty" Result: "empty" |
Last Item |
Gets the last value in a list. Values - Input Expected When Empty - Object type. This is returned when the input value is invalid Object - Return Value |
Values: {1, 2, 3} Expected When Empty: 0 Result: 3 |
The Function Wizard content varies according to the selected function: