An expression is a set of instructions that combine one or more values, operators, functions, and/or JSONPath queries to calculate a value or produce a result.

Prerequisites

Before you start with expression basics, you should have a good understanding of JSONPath Basics

A first Expression

An expression is always encapsulated with curly brackets {}.

For example, consider the following JSON:

{
    "first_name": "John",
    "last_name": "Wayne",
    "role": "Admin",
    "email": "test@test.com"
}
CODE

The simplest example of an expression is encapsulating a JSONPath:

{$.last_name}
CODE

This expression will be resolved to Wayne

Alternative if Empty of Missing

If you want to handle empty or missing JSONPath queries, use the || operator.

{$.neverExists || $.last_name || 'unknown'}
CODE

This expression will at first try to resolve $.neverExists which does not exist in our example. As a fallback, it will resolve $.last_name to Wayne. If this field is empty as well, it would fallback to the hardcoded value unknown.

Nullable Expressions

In case you expect null or empty values, you can prevent the JSONPath from failing by marking the expression with a preluding question mark.

{?$.neverExists}
CODE

This will try to resolve $.neverExtist but return an empty string and not fail.

Functions

An expression can also resolve predefined functions to manipulate the data. You can find a comprehensive list of all available functions here.

As an example you can use the following expression to extract the email field and pass it to a custom function that returns the Atlassian accountID of the email if available:

{ GET_ACCOUNT_ID_BY_MAIL(( $.email )) }
CODE

Multi Expressions

Value fields also support multiple expressions to build more complex values.

For example, consider the following JSON:

{
    "first_name": "John",
    "last_name": "Wayne",
    "role": "Admin",
    "email": "test@test.com"
}
CODE

Using expressions, you could create a value that contains more values of this JSON and add custom characters:

{$.last_name}, {$.first_name} <{$.role}>
CODE

This multi-expression would return:

Wayne, John <Admin>
CODE