Skip to main content
Skip table of contents

Functions

External Data for Jira Fields offers various functions you can use to transform values that you want to use in your Field Configurations.

DECODE_HTML

The DECODE_HTML function is used to decode HTML encoded strings for a given JSONPath.

Usable: Value Fields, Context Filter, Variables

Syntax: { DECODE_HTML((PARAM_1)) }

Parameter

Type

Examples

Description

PARAM_1

JSONPath

$.value

$.issue.fields.customfield_XXXXX

The JSONPath expression representing the value that should be decoded

Value Field Example

For example, consider the following data source JSON:

CODE
{
  "value": "100 €"
}

 

Use the DECODE_HTML function to decode all HTML encoded elements

CODE
{ DECODE_HTML(($.value)) }

This will result in 100 €

FORMAT_DATE

The FORMAT_DATE function is used to format a date time value.

Usable: Value Fields, Variables

Syntax: { FORMAT_DATE(( PARAM_1 PARAM_2 PARAM_3 )) }

Parameter

Type

Examples

Description

PARAM_1

JSONPath

$.value

The JSONPath expression representing the date and time that should be formatted

PARAM_2

string

'd', 'D', 'f', 'F', 'g', 'G', 'm', 'o', 'r', 's', 't', 'T', 'u', 'U', 'Y'

The format specifier.

PARAM_3

string

'en-US', 'de-DE', 'es-ES', 'fr-FR', etc.

The culture.

Value Field Example

For example, consider the following data source JSON:

CODE
{
  "value": "2020-09-01T22:05:45.488+02:00"
}

Use the FORMAT_DATE function to format the value to a date string

CODE
{ FORMAT_DATE(( $.value 'g' 'de-DE' )) }

This will result in 01.09.2020 20:05

Format and Culture Examples

Format Specifier

Culture

Result

d

de-DE

31.10.2008

d

en-US

10/31/2008

d

es-ES

31/10/2008

D

de-DE

Freitag, 31. Oktober 2008

D

en-US

Friday, October 31, 2008

D

fr-FR

vendredi 31 octobre 2008

f

en-US

Friday, October 31, 2008 5:04 PM

F

en-US

Friday, October 31, 2008 5:04:32 PM

g

en-US

10/31/2008 5:04 PM

G

en-US

10/31/2008 5:04:32 PM

m

en-US

October 31

o

en-US

2008-10-31T17:04:32.0000000

r

en-US

Fri, 31 Oct 2008 17:04:32 GMT

s

en-US

2008-10-31T17:04:32

t

en-US

5:04 PM

T

en-US

5:04:32 PM

u

en-US

2008-10-31 17:04:32Z

U

en-US

Friday, October 31, 2008 9:04:32 AM

Y

en-US

October 2008

GET_ACCOUNT_ID_BY_MAIL

The GET_ACCOUNT_ID_BY_MAIL function converts an email address extracted from a JSON data source into an Atlassian accountID. It uses a JSONPath expression to locate the email in your data, and then queries the Atlassian system to return the corresponding accountID.

Usable in: Value Fields, Variables

Syntax: { GET_ACCOUNT_ID_BY_MAIL(( PARAM_1 PARAM_2 )) }

Parameter

Type

Examples

Description

PARAM_1

string

$.email

The JSONPath expression that returns an email that should be converted into an accountID

PARAM_2

Optional string

'atlassian'

Optional value that allows to filter by account type of a user. Possible values are 'atlassian' or 'customer'

Note: The “PARAM_2” parameter was introduced to address scenarios where multiple accounts may share the same email address. By default, the function returns the first account that matches the search criteria. In the event that several accounts exist, please enter PARAM_2 to ensure that the function selects the correct account type.

Value Field Example

Assume the following example JSON data source:

CODE
{
  "name": "Mario",
  "email": "test@test.com"
}

Basic Conversion:
Convert the email to an accountID without specifying an account type will return the first match:

CODE
{ GET_ACCOUNT_ID_BY_MAIL(( $.email )) }

Returns an accountID, for example, '12345678910'.

Filter for an Atlassian account:

Use the GET_ACCOUNT_ID_BY_MAIL in combination with the 'atlassian' filter to convert the email to an accountID with the account type being atlassian.

CODE
{ GET_ACCOUNT_ID_BY_MAIL(( $.email 'atlassian' )) }

Returns the accountID associated with the Atlassian account type, for example, '12345678910'.

User Picker Usage

The GET_ACCOUNT_ID_BY_MAIL function is commonly used in combination with a dependent field targeting a native Jira user picker field. In order to set the value of the user picker field, the accountID is required, which may not be readily available in your data source. This function helps you convert existing emails to the required accountID, making it easier to set the value of the user picker field.

JOIN

The JOIN function is used to concatenate multiple strings with a specified delimiter in between for a given JSONPath array.

Usable: Value Fields, Context Filter, Variables

Syntax: { JOIN((PARAM_1 PARAM_2)) }

Parameter

Type

Examples

Description

PARAM_1

JSONPath array

$.result[*].name

$.issue.fields.customfield_X[*].value

The JSONPath expression representing the array that should be concatenated.

PARAM_2

String

'|'
'&'

Character used as delimiter

Value Field Example

For example, consider the following data source JSON:

CODE
{
  "result": [
    {
      "name": "Mario",
    },
    {
      "name": "Luigi",
    }
  ]
}

 

Use the JOIN function to concatenate the JSONPath names with the & symbol

CODE
{ JOIN(($.result[*].name '&')) }

This will result in Mario & Luigi

Context Filter Example

Use the JOIN function to build part of a regular expression by concatenating the values with the pipe symbol

CODE
$.result[?(@.name=~/({ JOIN(( $.issue.fields.customfield_10XXX[*].value '|' )) })/i )]

If $.issue.fields.customfield__X contains a list of Mario and Luigi the expression will result in:

CODE
$.result[?(@.name=~/(Mario|Luigi)/i )]

OFFSET_FORMAT_DATE

The OFFSET_FORMAT_DATE function is used to set a timezone offset and then format a date time value.

Usable: Value Fields, Variables

Syntax: { OFFSET_FORMAT_DATE(( PARAM_1 PARAM_2 PARAM_3 PARAM_4 )) } }

Parameter

Type

Examples

Description

PARAM_1

JSONPath

$.value

The JSONPath expression representing the date and time that should be formatted.

PARAM_2

string

'+8','-8'

The timezone offset. The offset should be specified in hours and can be positive or negative.

PARAM_3

string

'd', 'D', 'f', 'F', 'g', 'G', 'm', 'o', 'r', 's', 't', 'T', 'u', 'U', 'Y'

The format specifier for the output date string.

PARAM_4

string

'en-US', 'de-DE', 'es-ES', 'fr-FR', etc.

The culture used for formatting the output date string.

Value Field Example

For example, consider the following data source JSON:

CODE
{
  "value": "2020-09-01T22:05:45.488+02:00"
}

To format the value to a date string with an offset of +8, use the OFFSET_FORMAT_DATE function to format the value to a date string

CODE
{ OFFSET_FORMAT_DATE(( $.time '+8' 'g' 'en-AU' )) }

This will result in 2/9/2020 4:05 am

Format and Culture Examples

Format Specifier

Culture

Result

d

de-DE

31.10.2008

d

en-US

10/31/2008

d

es-ES

31/10/2008

D

de-DE

Freitag, 31. Oktober 2008

D

en-US

Friday, October 31, 2008

D

fr-FR

vendredi 31 octobre 2008

f

en-US

Friday, October 31, 2008 5:04 PM

F

en-US

Friday, October 31, 2008 5:04:32 PM

g

en-US

10/31/2008 5:04 PM

G

en-US

10/31/2008 5:04:32 PM

m

en-US

October 31

o

en-US

2008-10-31T17:04:32.0000000

r

en-US

Fri, 31 Oct 2008 17:04:32 GMT

s

en-US

2008-10-31T17:04:32

t

en-US

5:04 PM

T

en-US

5:04:32 PM

u

en-US

2008-10-31 17:04:32Z

U

en-US

Friday, October 31, 2008 9:04:32 AM

Y

en-US

October 2008

QUOTED_JOIN

The QUOTED_JOIN function is used to concatenate multiple strings with a specified delimiter in between for a given JSONPath array. In addition all strings are surrounded by single quotes.

Usable: Value Fields, Context Filter, Variables

Syntax: { QUOTED_JOIN((PARAM_1 PARAM_2 PARAM_3)) }

Parameter

Type

Examples

Description

PARAM_1

JSONPath array

$.result[*].name

$.issue.fields.customfield_X[*].value

The JSONPath expression representing the array that should be concatenated.

PARAM_2

Optional string

'|'
'&'

Character used as delimiter

PARAM_3

Optional string

'\"'

Character used as quotes

Value Field Example

For example, consider the following data source JSON:

CODE
{
  "result": [
    {
      "name": "Mario",
    },
    {
      "name": "Luigi",
    }
  ]
}

 

Use the QUOTED_JOIN function to concatenate the JSONPath names with the & symbol

CODE
{ QUOTED_JOIN(($.result[*].name '&')) }

This will result in 'Mario' & 'Luigi'

Context Filter Example

Use the QUOTED_JOIN function to build part of a regular expression by concatenating the values with the pipe symbol

CODE
$.result[?(@.name=~/({ QUOTED_JOIN(( $.issue.fields.customfield_10XXX[*].value '|' )) })/i )]

If $.issue.fields.customfield__X contains a list of Mario and Luigi the expression will result in:

CODE
$.result[?(@.name=~/('Mario'|'Luigi')/i )]

REGEX_IN_ARRAY

The REGEX_IN_ARRAY function is used to build a regular expression pattern from an array of values to perform a context filter operation. The resulting regex pattern is in the form /(VALUE1|VALUE2|...)/i.

Usable: Context Filter, Variables

Syntax: { REGEX_IN_ARRAY(( PARAM_1 PARAM_2)) }

Parameter

Type

Example

Description

PARAM_1

JSONPath Array

$.user.groups.items[*].name

A list of values that will be used to build the regular expression pattern. Can be used to retrieve context values from $.issue.... or $.user....

PARAM_2

Optional string

‘fullMatch'
'exact'

Optional value that supports two optional matching modes: fullMatch and exact, which affect how the resulting regular expression is constructed and applied.

Matching Modes

The PARAM_2 values in the REGEX_IN_ARRAY function changes how the values in the array are matched and what options are added to the regular expression.

Mode

Syntax Example

Anchors

Description

Default

{ REGEX_IN_ARRAY(( $.user.groups.items[*].name )) }

/(...)/i

Partial Match.

Behaves like contains while being case-insensitive

FullMatch

{ REGEX_IN_ARRAY(( $.user.groups.items[*].name 'fullMatch' )) }

/^(...)$/i

Adds the ^ and $ anchors.

Fully matches the strings while being case-insensitive

Exact

{ REGEX_IN_ARRAY(( $.user.groups.items[*].name 'exact' )) }

/^(...)$/

Adds the ^ and $ anchors and removes the i options.

Fully matches the strings while being case-sensitive

Context Filter Example

For example, consider the following data source JSON:

CODE
{
  "result": [
    {
      "id": 1,
      "group": "administrators",
      "name": "Mario Speedwagon",
      "username": "mario"
    },
    .... more items here ....
  ]
}

To filter results based on whether the current user’s groups matches one of the values in the JSON array, use the following expression:

CODE
$.result[?(@.group=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name )) })]

If $.user.groups.items[*].name contains administrators and jira-core-users the expression will resolve to the regular expression

CODE
$.result[?(@.group=~/(administrators|jira-core-users)/i)]

 Same but with an array of groups in your data source

CODE
{
  "result": [
    {
      "id": 1,
      "groups": ["administrators","jira-servicedesk-users"],
      "name": "Mario Speedwagon",
      "username": "mario"
    },
    .... more items here ....
  ]
}
CODE
$.result[?(@.group[?(@=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name )) })])]

If $.user.groups.items[*].name contains administrators and jira-core-users the expression will resolve to the regular expression

CODE
$.result[?(@.group[?(@=~/(administrators|jira-core-users)/i)])]

Mode Differences

Compare the resolved regular expression from the example above with all different modes and resolved anchors.

Default

CODE
$.result[?(@.group=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name )) })]
CODE
$.result[?(@.group=~/(administrators|jira-core-users)/i)]

FullMatch

CODE
$.result[?(@.group=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name 'fullMatch')) })]
CODE
$.result[?(@.group=~/^(administrators|jira-core-users)$/i)]

Exact

CODE
$.result[?(@.group=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name 'exact')) })]
CODE
$.result[?(@.group=~/^(administrators|jira-core-users)$/)]

Anchor Effects

Anchor

Meaning

^

Start of the string

$

End of the string

None

Partial/substring matching

Construct Regex with JOIN function

We use the method documented here to resolve the regex expression, but only support the options i, m, s, and x.

If the REGEX_IN_ARRAY function is constructing the expression in a way that is not feasible for your use case, you can use the JOIN function to construct an expression ‘manually’.

Instead of using $.result[?(@.group[?(@=~{ REGEX_IN_ARRAY(( $.user.groups.items[*].name )) })])] you can also use $.result[?(@.group[?(@=~/({ JOIN(( $.user.groups.items[*].name '|')) })/i)])]. This way, you are more flexible how to anchor or combine your expression.

REGEX_MATCH

The REGEX_MATCH function is used to match a regular expression pattern against a string content.

We use the method documented here to resolve the regex expression, but only support the options i, m, s, and x.

Usable: Value Fields, Context Filter, Variables

Syntax: { REGEX_MATCH((PARAM_1 PARAM_2)) }

Parameter

Type

Example

Description

PARAM_1

JSONPath value

$.issue.fields.customfield_X
$.value

The JSONPath expression representing the value that should be matched against the regular expression pattern.

PARAM_2

String

'^([^\s]*)'

The regular expression pattern to match against the value in PARAM_1

Value Field Example

Extract all text up to the first whitespace:

CODE
{ REGEX_MATCH(($.value '^([^\s]*)')) }

If $.value contains '12345 (branch/name)' the result will be 12345.

Context Filter Example

For example, consider the following data source JSON:

CODE
{
  "result": [
    {
      "id": 1,
      "group": "administrators",
      "name": "Mario Speedwagon",
      "username": "mario"
    },
    .... more items here ....
  ]
}

To filter results in which the id equals the custom field value of the issue until the first whitespace:

CODE
$.result[?(@.id=={ REGEX_MATCH(($.issue.fields.customfield_X '^([^\s]*)')) } )]

If the $.issue.fields.customfield__X field contains '1 (branch/name)' the resolved expression will be:

CODE
$.result[?(@.id==1)]

REGEX_GROUP_MATCH

The REGEX_GROUP_MATCH function is used to match a regular expression pattern against a string content and retrieve a specific declared group.

We use the method documented here to resolve the regex expression, but only support the options i, m, s, and x.

Usable: Value Fields, Context Filter, Variables

Syntax: { REGEX_GROUP_MATCH((PARAM_1 PARAM_2 PARAM_3)) }

Parameter

Type

Examples

Description

PARAM_1

JSONPath value

$.issue.fields.customfield_X
$.value

The JSONPath expression representing the value that should be matched against the regular expression pattern.

PARAM_2

String

'\((\S*)\)'

The regular expression pattern to match against the value in PARAM_1

PARAM_3

String

'1'
'2'

The matching group that should be used

Value Field Example

Get the value of the second group match

CODE
{ REGEX_GROUP_MATCH(($.value '^([^\s]*)' '2')) }

If $.value contains 'the name (7) (test)' the result will be test.

Context Filter Example

To filter results where the “id” equals the custom field value of the issue at the first quotes:

CODE
{ REGEX_GROUP_MATCH(($.issue.fields.customfield_X '\((\S*)\)' '1')) }

If the $.issue.fields.customfield__X field contains 'the name (7) (test)' the expression will resolve to:

CODE
$.result[?(@.id=='7')]

REGEX_REPLACE

The REGEX_REPLACE function is used to match a regular expression pattern against a string content and replace all matches with a given string.

We use the method documented here to resolve the regex expression, but only support the options i, m, s, and x.

Usable: Value Fields, Context Filter, Variables

Syntax: { REGEX_REPLACE((PARAM_1 PARAM_2 PARAM_3)) }

Parameter

Type

Example

Description

PARAM_1

JSONPath value

$.issue.fields.customfield_X
$.value

The JSONPath expression representing the value that should be matched against the regular expression pattern.

PARAM_2

String

'[^a-zA-Z0-1 ]'

The regular expression pattern to match against the value in PARAM_1

PARAM_3

String

'replace'

''

The replacing String of each match

Value Field Example

Extract all text up to the first whitespace:

CODE
{ REGEX_REPLACE(($.value '[^a-zA-Z0-1 ]' '')) }

If $.value contains '[remove] all // unwanted {}'&^!@^&($ characters' the result will be remove all unwanted characters.

Context Filter Example

For example, consider the following data source JSON:

CODE
{
  "result": [
    {
      "id": 1,
      "group": "administrators",
      "name": "Mario Speedwagon",
      "username": "mario"
    },
    .... more items here ....
  ]
}

To filter results in which the id equals the custom field value of the issue until the first whitespace:

CODE
$.result[?(@.id=={ REGEX_REPLACE(($.issue.fields.customfield_X '[^0-1 ]' '')) } )]

If the $.issue.fields.customfield__X field contains '1 (branch/name)' the resolved expression will be:

CODE
$.result[?(@.id==1)]

because only numbers are allowed and other characters are removed

REPLACE

The REPLACE function is used to replace all occurrences of a specified string with another string in a given JSONPath value.

Usable: Value Fields, Context Filter, Variables

Syntax: { REPLACE((PARAM_1 PARAM_2 PARAM_3)) }

Parameter

Type

Example

Description

PARAM_1

JSONPath value

$.issue.fields.customfield_X
$.value

The JSONPath expression representing the value that should be matched against the regular expression pattern.

PARAM_2

String

'origin'
' '

This represents the string to be replaced.

PARAM_3

String

'replace'
'|'

This represents the string to replace the matches specified in PARAM_2.

Value Field Example

Use the REPLACE function to replace all spaces in the JSONPath value with the pipe symbol

CODE
{ REPLACE(($.value ' ' '|')) }

If $.value contains 'This is a string' the result will be This|is|a|string.

Context Filter Example

Use the REPLACE function to replace all spaces in the JSONPath value with the pipe symbol

CODE
$.result[?(@.value=~/({ REPLACE(( $.issue.fields.customfield_10XXX ' ' '|' )) })/i )]

If $.issue.fields.customfield__X contains 'This is a string' the expression will be:

CODE
$.result[?(@.value=~/(This|is|a|string)/i )]

STRIP_HTML

The STRIP_HTML function is used to remove all HTML for a given JSONPath value.

Usable: Value Fields, Context Filter, Variables

Syntax: { STRIP_HTML((PARAM_1)) }

Parameter

Type

Examples

Description

PARAM_1

JSONPath

$.value

$.issue.fields.customfield_X

The JSONPath expression representing the value that should be stripped off HTML

Value Field Example

For example, consider the following data source JSON:

CODE
{
  "value": "<p><b>title</b><br/>subtitle</p>"
}

Use the STRIP_HTML function remove all HTML elements and convert <br> tags into line breaks

CODE
{ STRIP_HTML(($.value)) }

This will result in title\nsubtitle.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.