On this page |
Throughout the documentation we refer to data types that can be used in Jira expression. The most commonly use data types are listed below. Apart from this list, learn more about data types in Jira expressions in the general documentation.
Data type | Description | Example |
---|---|---|
This type represents numeric values. | 1, 1.1, -1.1, .1, -.1 | |
This type represents a collection of numeric values. The size may vary from 0 to any number of numeric values. It is used to read the value of a numeric field in a selection of issues. You can also use literals like
[1, 2, 3]
. | [1, 2, 3] | |
This type represents any kind of text or character string including all kinds of select and multi-select fields. | "Hello world" | |
| This type represents a collection of textstring values. The size may vary from 0 to any number of string values. It is also used to read the value of a string field in a selection of issues. You can also use literals like
["string_A", "string_B", "string_C"]
. | ["string_A", "string_B", "string_C"] |
A logical, or boolean, value of true or false . | true |
All numbers in Jira expressions are double-precision 64-bit IEEE 754 floating points. The usual set of mathematical operations is available.
Strings can be converted to numbers with the Number function. For example:
Number('1') + Number('2') == 3 |
Note that if a string cannot be parsed as number, the function returns NaN (Not a Number).
Texts are based on the JavaScript String object.
Currently supported properties and functions are:
Function | Output | Returned value |
---|---|---|
length | The text length | |
trim() | Removes whitespaces from beginning and end | |
toLowerCase() | Returns the same string with all characters in lowercase | |
toUpperCase() | Returns the same string with all characters in uppercase | |
split(string?) | Splits the string with the given separator | |
replace(string, string|string => string) | Replaces all occurrences of the first argument with the second argument, which can also be a function that accepts the matched part | |
match(string) | Finds all matches of the given regular expression in this string | |
includes(string) | Returns true if this string contains the given string, false otherwise | |
indexOf(string) | Returns the index of the first occurrence of the given string in this string, or -1 | |
slice(number, number?) | Returns a substring of this string, according to the given arguments |
Rich text
This object represents fields with rich text formatting. Currently it allows to retrieve only plain text, but in the future it will also contain Atlassian Document Format.
plainText
: The plain text stored in the field ().To access such a property you can easily call it by using an expression like:
issue.description.plainText
This object is based on the JavaScript Date API.
Read more about dates and times in Jira expressions in the general documentation.
Jira expressions provide these additional functions:
Function | Output | Returned value |
---|---|---|
toString() | Returns a string in the human-readable format, according to the current user's locale and timezone | |
toCalendarDate() | Transforms this into a calendar date, according to the current user's locale and timezone | |
toCalendarDateUTC() | Transforms this into a calendar date in the UTC timezone | |
plusMonths(number) | Returns a date with the given number of months added | |
minusMonths(number) | Returns a date with the given number of months removed | |
plusDays(number) | Returns a date with the given number of days added | |
minusDays(number) | Returns a date with the given number of days removed | |
plusHours(number) | Returns a date with the given number of hours added | |
minusHours(number) | Returns a date with the given number of hours removed | |
plusMinutes(number) | Returns a date with the given number of minutes added | |
minusMinutes(number) | Returns a date with the given number of minutes removed |
new Date()
: Creates a date that represents the current time.new Date(number)
: Creates a date based on a number of milliseconds that elapsed since the Unix epoch.new Date(string)
: Creates a date based on a string in the ISO 8601 format (for example, 2008-09-15T15:53:00+05:00
). The current user's timezone is used if none is included in the string.A time-zone agnostic Date with the same set of methods, but limited only to year, month, and day.
new CalendarDate(string)
: Creates a calendar date based on a string in the yyyy-MM-dd format. For example, 2018-09-15
.
Lists are a basic building block of Jira expressions. By design, the language does not support imperative constructs, so instead of writing loops, you need to employ the functional style of processing lists with lambda functions.
For example, to return the number of comments with contents longer than 100 characters:
issue.comments .map(c => c.body.plainText) .filter(text => text.length > 100) .length |
You can access individual elements of a list by using an index, e.g. issue.attachments[0].author.displayName
returns the name of the author of the issue's first attachment.
The following properties and functions are available for lists:
Function | Output | Returned value |
---|---|---|
length | Returns the number of items stored in the list | |
map(Any => Any) | Maps all items in the list to the result of the provided function | |
sort((Any, Any) => Number) | Returns the list sorted by the natural ordering of elements or by the optional comparison function | |
filter(Any => Boolean) | Leaves only items that do satisfy the given function, that is, for which the given function returns true | |
every(Any => Boolean) | Checks if all elements in the list satisfy the given predicate | |
some(Any => Boolean) | Checks if the list contains at least one element that satisfies the given predicate | |
includes(Any) | Checks if the given argument is stored in the list | |
indexOf(Any) | Returns the index of the first occurrence of the item in the list, or -1 | |
slice(Number, Number?) | Returns a portion of the list, with the index starting from the first argument (inclusive), and ending with the second one (exclusive). The second argument is optional, if not provided, all remaining elements will be returned. Negative numbers are allowed and mean indexes counted from the end of the list | |
flatten() | Flattens a multi-dimensional list | |
flatMap(Any => Any) | Maps all items in the list and flattens the result | |
reduce(Any => Any, Any?) | Aggregates all elements of the list using the function provided in the first argument. The operation starts from the first element of the list, unless the initial value is provided in the optional second argument. If the list is empty and no initial value is given, an error will be returned. |
If the returned property value is a JSON object, it will be converted to a Map.
map.key
is the same as map['key']
.get()
method. For example, map.get('key')
.null
if there is no mapping for the given key.To create a new map, write new Map()
. Object literals are also evaluated to the Map object. For example, { id: issue.id, summary: issue.summary }
will evaluate to a map with two keys: id and summary.
Apart from static and computed member access, the following methods are available for maps:
get(string)
: Returns the value mapped to the given key, or null
(Any).set(string, Any)
: Returns a new map that has all entries from the current map, plus the first argument mapped to the second (Map).entries()
: Returns a list of all entries in this map, each entry returned as a two-element list of key and value (List<[String, Any]>).new Map()
: Creates an empty map. Equivalent to {}.Accessing properties in a Jira expression may fail, for example, where:
null
. For example, in the expression a.b where the value of a
is null
.the property does not exist.
In expressions where such strict rules are not desired, use the optional chaining operator ?.
. This operator behaves in the same way as regular member access, but with one crucial difference: when accessing the property fails, null
is returned.
Examples:
issue.properties?.myProperty?.a?.b
—this expression returns null
if there is no myProperty
defined in the issue, or if there is no a.b
path in the value of the property.issue?.customfield_10010
—this expression returns null
if the custom field doesn't exist.The operator can also be used in combination with computed member access, for example: issue?.[fieldName]
.
There are two boolean values: true
and false
.
The usual set of logical operators, with behavior following the rules of classical boolean algebra, is available:
Operator | Example |
---|---|
conjunction | a && b |
disjunction | |
negation | !a |