Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
The data structure used to hold both the Advanced Row Field and the Advanced Table Field is a bi-dimensional string array. In SIL terms it is expressed like this:
Code Block |
---|
string[][] fieldVal; |
The particularities for the Advanced Row Field are:
the array’s first dimension size is equal to the number of values that the field stores (1 for Simple select, Autocomplete and Generic field or N - number of selected values - for Multiselect);
the array’s second dimension size is equal to the number of columns that are configured for the field.
Advanced Database Row Field can be used in SIL scripts to both read and write values into issues.
Let’s take the following Advanced Row Field as example:
Get the field value
Given the field above, the following SIL code would be used to obtain the fields value for the issue with key ‘key’:
Code Block |
---|
string[][] fieldVal = %key%.customfield_10300; return fieldVal; |
Result - 10|ES|Spain|1492-10-12|30103.51|Madrid|true
Info |
---|
The formatting (pipe delimited) of these results tell us that the returned value is an array. Using a pipe delimited string is a shortcut for reading and writing values to an array. SIL will automatically convert the string to an array. |
If we run the same script for an Autocomplete Advanced Row Field (configured with id and name as columns):
Result - 10|Spain
If we run the same script for a Multiselect Advanced Row Field (configured with id and name as columns), having multiple values already selected:
Result - 2|Germany|3|France
Get the value of a field’s column
To retrieve a specific Advanced Row Field’s value for a issue and column we can use an array like below. In this example we will retrieve the country name:
Code Block |
---|
string[][] fieldVal = %key%.customfield_10300; return fieldVal[0][2]; |
Result - Spain
Info |
---|
The ‘name’ column is at position 2 of the array and not position 3 because when counting the positions within an array you must always start with 0. |
Similarly, to retrieve the country’s capital, we use the following:
Code Block |
---|
string[][] fieldVal = %key%.customfield_10300; return fieldVal[0][5]; |
Result - Madrid
For an Autocomplete Advanced Row Field (configured with id and name as columns) we can only retrieve columns with index 0 (id) or 1 (name):
Code Block |
---|
string[][] fieldVal = %key%.customfield_10400; return fieldVal[0][0]; |
Result - 10
Code Block |
---|
string[][] fieldVal = %key%.customfield_10400; return fieldVal[0][1]; |
Result - Spain
For a Multiselect Advanced Row Field (configured with id and name as columns) we can only retrieve columns with index 0 (id) or 1 (name), but we can extract them from each of the values the multiselect holds (notice the first index):
Code Block |
---|
string[][] fieldVal = %key%.customfield_10500; return fieldVal[0][2]; |
Result - Germany
Code Block |
---|
string[][] fieldVal = %key%.customfield_10500; return fieldVal[1][2]; |
Result - France
Set the field value
To set the value for an The Advanced Row Field , you will need to provide it with value should be set using a bi-dimensional array:
Code Block |
---|
%key%.customfield_10300 = {{10, "ES", "Spain", "1492-10-12", "30103.51", "Madrid", true}}; |
The same syntax is valid for read-only an Autocomplete Advanced Row Fields Field (configured with id and name as columns):
Code Block |
---|
%key%.customfield_10400 = {{10, "Spain"}}; |
If you need to set multiple values to a Multiselect Advanced Row Field (configured with id and name as columns), here is an example:
Code Block |
---|
%key%.customfield_10500 = {{2, "Germany"}, {3, "France"}}; |
Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
See More
Child pages (Children Display) | ||
---|---|---|
|