You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

General Information

Throughout the documentation we refer to data types that can be used in Jira expression. The most commonly use data types are listed below.


Data typeDescriptionExample

NUMBER

This type represents numeric values, and is also used to store Date, Time and Date-Time (DATE_TIME) values. Number fields can be referenced as numbers using the following notation: {...somefield}.

1, 1.1, -1.1, .1, -.1

STRING

This type represents any kind of text or character string including all kinds of select and multi-select fields MULTI.

Pro tip

Any field type or data type is susceptible of being transformed to text, so any field can be referenced as a text-string value using the following notation: %{...somefield}, and %{...somefield.i} for Cascading Select fields, where i is the index that represents the level to be accessed. (i = 0 is used for base level).
"Hello world"

NUMBER []

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]

STRING []

This type represents a collection of string 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"]

Numbers

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 cast to numbers with the Number function. For example:
Copy
1 Number('1') + Number('2') == 3

Note that if a string cannot be parsed as number, the function returns NaN (Not a Number).

Strings

Strings are based on the JavaScript String object.

Currently supported properties and methods are:

  • length: The string length (Number).
  • trim(): Removes whitespaces from beginning and end (String).
  • toLowerCase(): Returns the same string with all characters in lowercase (String).
  • toUpperCase(): Returns the same string with all characters in uppercase (String).
  • split(string?): Splits the string with the given separator (List<String>).
  • 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 (String).
  • match(string): Finds all matches of the given regular expression in this string (List<String>).
  • includes(string): Returns true if this string contains the given string, false otherwise (Boolean).
  • indexOf(string): Returns the index of the first occurrence of the given string in this string, or -1 (Number).
  • slice(number, number?): Returns a substring of this string, according to the given arguments (String).

Dates

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 methods:

  • toString(): Returns a string in the human-readable format, according to the current user's locale and timezone (String).
  • toCalendarDate(): Transforms this into a calendar date, according to the current user's locale and timezone (CalendarDate).
  • toCalendarDateUTC(): Transforms this into a calendar date in the UTC timezone (CalendarDate).
  • plusMonths(number): Returns a date with the given number of months added (Date).
  • minusMonths(number): Returns a date with the given number of months removed (Date).
  • plusDays(number): Returns a date with the given number of days added (Date).
  • minusDays(number): Returns a date with the given number of days removed (Date).
  • plusHours(number): Returns a date with the given number of hours added (Date).
  • minusHours(number): Returns a date with the given number of hours removed (Date).
  • plusMinutes(number): Returns a date with the given number of minutes added (Date).
  • minusMinutes(number): Returns a date with the given number of minutes removed (Date).

Constructors

  • 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.

Calendar Date

A time-zone agnostic Date with the same set of methods, but limited only to year, month, and day.

Constructors

  • new CalendarDate(string): Creates a calendar date based on a string in the yyyy-MM-dd format. For example, 2008-09-15.

Lists

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, first map the comments to their texts, then filter them to leave only those long enough, and finally get the length of the resulting list:
Copy
1 2 3 4 issue.comments .map(c => c.body.plainText) .filter(text => text.length > 100) .length

The following properties and methods are available for lists:

  • length: Returns the number of items stored in the list (Number).
  • map(Any => Any): Maps all items in the list to the result of the provided function (List).
  • sort((Any, Any) => Number): Returns the list sorted by the natural ordering of elements or by the optional comparison function (List).
  • filter(Any => Boolean): Leaves only items that do satisfy the given function, that is, for which the given function returns true (List).
  • every(Any => Boolean): Checks if all elements in the list satisfy the given predicate (Boolean).
  • some(Any => Boolean): Checks if the list contains at least one element that satisfies the given predicate (Boolean).
  • includes(Any): Checks if the given argument is stored in the list (Boolean).
  • indexOf(Any) Returns the index of the first occurrence of the item in the list, or -1 (Number).
  • 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 (List).
  • flatten(): Flattens a multi-dimensional list (List).
  • flatMap(Any => Any): Maps all items in the list and flattens the result (List).
  • 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.


Maps

If the returned property value is a JSON object, it will be converted to a Map.

  • Static or dynamic member access can be used to retrieve values from a map. For example, map.key is the same as map['key'].
  • Values can also be accessed using the get() method. For example, map.get('key').
  • Both of these methods will return 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]>).

Constructors

  • new Map(): Creates an empty map. Equivalent to {}.

Boolean

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:

  • conjunction (for example, a && b),
  • disjunction (for example, a || b),
  • negation (for example, !a).