index( data, index, default )
Returns the data[index] if it is valid or else returns the default value.
See also: property(): This function acts as an alias to the index() function especially when applied over custom data types.
Keyword | Type | Description |
---|---|---|
|
Any Type |
A homogeneous array, whose indexed value is expected. Can also be a dictionary, map, CDT, or Record. |
|
Any Type |
The index or array of indices of the data. Index can be an integer, text, or a record type field reference. |
|
Any Type |
The default value to be returned if the data or the index is invalid, e.g. if the data itself is empty or the index is not found in the data. The type of the default value must be the same as that of the elements of the data. This parameter is optional. |
Any Type
The type of the default value must be same as that of the elements in the array.
When the data is a dictionary, if the index is not found in the dictionary, the default will be ignored and a null value will be returned. Consider using a map instead of a dictionary.
index({10, 20, 30}, 2, 1)
returns 20
index(pv!person, "firstName", "")
returns the value of the "firstName" field in a CDT of person with two fields (firstName
and lastName
)
index({10, 20, 30}, {1, 3}, 0)
returns 10, 30
index({10, 20, 30}, {1, 1, 3}, 0)
returns 10, 10, 30
index(topaginginfo(1, 10), "startIndex", 0)
returns 1
index(a!map(a: 1, b: 2), "b", 0)
returns 2
index(recordType!Department(name: "Engineering"), recordType!Department.fields.name, "")
returns "Engineering"
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 | |
Process Reports | Compatible | |
Process Events | Compatible |
index() Function