Skip to main content
Skip table of contents

Context Filter

The context filter enables you to extract the relevant segment of your data source by utilizing contextual information such as issue fields or user values.
This feature is particularly useful when you need to establish a dependency between two fields or when you have a single JSON data block for all issues and need a specific section of that data. The context filter helps you navigate to the entry that contains the information you require.

Availability

Context filters are available in the following field configurations of the app:

  • Search Field

  • Info Panel

  • Dependant Field

Prerequisites

Before using the context filter feature, you should have a good understanding of

Available Issue Values

The values are contextual variables that allow you to filter your data source based on issue based variables such as:

Issue Key

$.issue.key

Issue Id

$.issue.id

Project Key

$.issue.fields.project.key

Project Name:

$.issue.fields.project.name

Custom field - Text

$.issue.fields.customfield_10XXX

Custom field - Select list

$.issue.fields.customfield_10XXX.value

Custom field - Cascading list child

$.issue.fields.customfield_10XXX.child.value

Issue Type - Name

$.issue.fields.issuetype.name

Issue Type - Id

$.issue.fields.issuetype.id

Issue Status - Name

$.issue.fields.status.name

Issue Status - Id

$.issue.fields.status.id

Asset field (External Assets Platform)

$.issue.fields.customfield_10XXX[0].originId

Organizations - Jira Service Management

$.issue.fields.customfield_10XXX[0].name

Assignee Account Id

$.issue.fields.assignee.accountId

Creator User Key

$.issue.fields.creator.ke

Creator Display Name

$.issue.fields.creator.displayName

See more detailed availability matrix here.

Context Filter Examples for Issue Values

Comparing number values without quotation

CODE
$.result[?(@.id=={$.issue.fields.customfield_10XXX})]

Comparing string values with quotation

CODE
$.result[?(@.name=='{$.issue.fields.customfield_10XXX}')]

Comparing against a custom field with fallback. More Information

CODE
$.result[?(@.name=='{$.issue.fields.customfield_12345 || $.issue.fields.customfield_65432}')]

Available User Values (Only in Search Field and Info Panel)

Some fields allow you to use variables about the current user and filter based on that information.

Account Id

$.user.accountId

Email Address

$.user.emailAddress

This field will be empty for most users due to GDPR compliance. Possible workaround in the FAQs

DisplayName

$.user.displayName

Active

$.user.active

User Groups

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

Application Roles

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

See more detailed availability matrix here.

Context Filter Examples for User Values

Compare against the current users name

CODE
$.result[?(@.name=='{$.user.displayName}')]

Compare against the current users first group name

CODE
$.result[?(@.role=='{$.user.groups.items[0].name}')]

Compare against multiple values at the same time by using regular expressions

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

Available Expression Functions

The following functions can be used to modify the data within the expression enclosed by curly brackets {}. You can find more detailed descriptions of these functions in the documentation's expression or function section:

{ REGEX_MATCH(($.issue.fields.customfield_10XXX 'regexPatternToMatch')) }

{ REGEX_GROUP_MATCH(($.issue.fields.customfield_10XXX 'patternWithGroupMatch' '1')) }

{ JOIN(($.issue.fields.customfield_10XXX[*].value ',' )) }

{ REPLACE(($.issue.fields.customfield_10XXX[*].value ',' ';' )) }

{ QUOTED_JOIN(($.issue.fields.customfield_10XXX[*].value ',' )) }

{ GET_ACCOUNT_ID_BY_MAIL(( $.mail )) }

{ STRIP_HTML(( $.myValueWithHTML )) }

{ DECODE_HTML(( $.myValueWithHTML )) }

{ STRIP_HTML(( DECODE_HTML(( $.myValueWithHTML )) )) }

{ FORMAT_DATE(( $.time 'd' 'en-Us' )) }

{ OFFSET_FORMAT_DATE(( $.time '+8' 'd' 'en-Us')) }

Regex Explained

CODE
$.result[?(@.role=~/(Owner)/g)]

This will return all results containing the word Owner

CODE
$.result[?(@.role=~/(Owner|Admin)/g)]

This will return all results containing the word Owner or Admin

CODE
$.result[?(@.role=~/^((?!Admin).)*$/g)]

This will return all results not containing the word Admin

JsonPath AND | OR

In rare cases you want to select multiple values at the same time by using AND && or OR ||.

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

The result of this filter would be the users with id 1 and 2.

CODE
$.result[?(@.role=='Owner' && @.id==2)]

The result of this filter would be empty because no user with the id 2 and the role of an owner exists.

Step by Step Explanation of a Context Filter

In the following we will use a data source with this Json result:

JSON
{
  "result": [
    {
      "id": 1,
      "role": "Owner",
      "name": "Mario Speedwagon",
      "username": "mario"
    },
    {
      "id": 2,
      "role": "Employee",
      "name": "Anna Sthesia",
      "username": "anna"
    },
    {
      "id": 3,
      "role": "Owner",
      "name": "Gail Forcewind",
      "username": "gail"
    }
  ]
}

and a custom fields:

CODE
customfield_10020 => contains role

Select Multiple Users by Role

In this example we look at all objects in $.result and select only those elements that have the role we want equal to the content of customfield_10020. See the following 3 steps to create a complex JsonPath based on issue values.

Step 1

select all users first

CODE
$.result[*]

Step 2

filter by role Owner in a static (not variable) way

CODE
$.result[?(@.role=='Owner')]

Step 3

the expression is final after replacing Owner with the issue based variable {$.issue.fields.customfield_10020}

CODE
$.result[?(@.role=='{$.issue.fields.customfield_10020}')]

The result of this filter will be

CODE
[
    {
        "id": 1,
        "role": "Owner",
        "name": "Mario Speedwagon",
        "username": "mario"
    },
    {
        "id": 3,
        "role": "Owner",
        "name": "Gail Forcewind",
        "username": "gail"
    }
]

Select Users by Context Groups

In this example we look at all objects in $.result and select only those elements that have the role based on the groups of the current user. See the following steps to create a complex JsonPath based on user values.

Step 1

select all users first

CODE
$.result[*]

Step 2

filter by role Owner in a static (not variable) way

CODE
$.result[?(@.role=='Owner')]

Step 3

introduction a context expression after replacing Owner with the user based variable {$.user.groups.items[0].name} which select the first group the current user is in.

CODE
$.result[?(@.role=='{$.user.groups.items[0].name}')]

Step 4

To show all users based on all groups instead of only the first one we use the following expression

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

The expression above will render

CODE
$.result[?(@.role=~/(Owner|Employee)/ig)]

JavaScript errors detected

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

If this problem persists, please contact our support.