Clone wiki

JIRA Workflow Toolbox / others / Examples of String List expressions

Examples of String List Expressions

This page presents a collection of string list expressions valid for JIRA Workflows Toolbox expressions parser.

String list is one of the data types that can be returned by an expression in JIRA Workflow Toolbox.

String List Literals

The syntax of a string list literal is a comma separated list of strings in double quotes written inside brackets. Examples:

ExpressionExample of Returned ValueNotes
[]Empty list.-
["red", "blue", "green"]String list with 3 strings.-
["Ada Lovelace", "John von Neuman", "Alan Turing"]String list with 3 strings.-

Reading Fields from Issue Lists

When we read field values from issues using field codes for string values (format %{nnnnn}), the returned data type is a string list.

ExpressionExample of Returned ValueNotes
fieldValue(%{00003}, subtasks())List of usernames of the assignees of the current issue's subtasks. It may contain repeated usernames.%{00003} = Assignee
distinct(fieldValue(%{00003}, subtasks()))List of usernames of the assignees of the current issue's subtasks. It will not contain repeated usernames, because of the usage of function distinct().%{00003} = Assignee
fieldValue(%{00017}, linkedIssues("blocks, is cloned by"))List of priorities of those issues linked to current issue through issue link types "blocks and "is cloned by".%{00017} = Priority

You will find very useful these examples of issue list expressions in order to select the issues you need to read fields from.

Reading Multivalued Fields as String Lists

Fields codes of multi-valued fields like Affected versions, Fixed versions, Components, Labels, Attachments, Watchers, Request Participants, Multi-Select List, Check List, Multi-User Picker, Multi-Group Picker and Multi-Version Picker custom fields, return a string with a comma separated list of values. We can convert this string into a string list by means of function toStringList().

ExpressionExample of Returned ValueNotes
toStringList(%{00074})If Fixed versions field code (i.e., %{00074}) returned "1.1, 1.2, 1.3", the expression would return ["1.1", "1.2", "1.3"]%{00074} = Fixed versions
toStringList(%{00094})String list with the components currently selected in field Components.%{00094} = Components

Reading Multi-valued Fields from Issue Lists

ExpressionExample of Returned ValueNotes
distinct(toStringList(toString(fieldValue(%{00094}, subtasks())), ","))Returns a string list with all the components present in the subtasks of current issue. The list obtained doesn't contain duplications, thanks to function distinct().%{00094} = Components

Parsing a String into a String List

We can use the following functions in order to parse a string into a string list:

FUNCTIONEXPLANATION
toStringList(string s, string separators) : string listINPUT: String with a list of tokens separated by one or more characters.
OUTPUT: A string list with tokens in argument s separated by characters in argument separators.
Example: toStringList("red, orange, yellow; green; blue; purple", ",;") returns the following string list: ["red", "orange", "yellow", "green", "blue", "purple"].
findPattern(string s, string regexp) : string listReturns a string list with all substrings in argument s matching regular expression in string argument regexp.
Example: findPattern("Between 1900 and 2000 world population increase from 1.5 to 6.1 billions.", "\\d+(\\.\\d+)?") returns ["1900", "2000", "1.5", "6.1"].
findPatternIgnoreCase(string s, string regexp) : string listReturns a string list with all substrings in argument s matching regular expression in string argument regexp. Evaluation of the regular expression is carried out in ignoring case mode.
Example: findPatternIgnoreCase("Grass is Green and Sky is Blue.", "red|green|blue") returns ["Green", "Blue"].

Updated