Skip to main content
Skip table of contents

Expression Basics

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:

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

The simplest example of an expression is encapsulating a JSONPath:

CODE
{$.last_name}

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.

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

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.

CODE
{?$.neverExists}

This will try to resolve $.neverExists 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:

CODE
{ GET_ACCOUNT_ID_BY_MAIL(( $.email )) }

Multi Expressions

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

For example, consider the following JSON:

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

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

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

This multi-expression would return:

CODE
Wayne, John <Admin>

 

JavaScript errors detected

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

If this problem persists, please contact our support.