Skip to main content
Skip table of contents

How to Create Two Nested (Dependant) Search Fields

Learning Goal: How to build dependent (or nested) search fields in a Jira Issue using “External Data for Jira”.

Learning Level: Advanced

Use Case: We have a huge customer list (“Tutorial Customer List”). We want to look up a specific customer and select one of their existing orders.

Before we begin, please make sure you meet the following basic requirements:

  • A Company Managed Project

  • Existing and activated Custom Search Fields

  • A Data Source

Configuring the Parent Search Field

Before we can set up a dependent search, we need to have an initial search field, that our second search will be dependent on. So our first step is to create and set up the parent search.

We do this by creating a default search field with our “Tutorial Customer List” as data source.

setting up the parent search using our demo tutorial customer list

We now need to add a JSON path, to filter the raw results. In our case, we want the JSONPath to refer to the company as the company name is supposted to be the inital search outcome we later want to refer to.

adding the JSON paths to filter the raw results

Explanation In Detail:

$.results[*].company: Our JSON list is named "results" - so we add that to our Select List Repository field like this. To parse all results from the list, we need to add an asterix in square brackets. Next step is to add the JSON path that refers to the company.

$.id: JSONPath to our id, which will be the unique identifier.

$..name: As our first search result is supposed to be the company name of our customer, we’ll put the JSONPath to the company’s name here. Same for the value field, in which the search result will be displayed later on.

Now we just have to select the target Jira Field which we have created beforehand, before we save and exit the parent search setup.

Configuring the Child Search Field

Now we need to create a search field that is dependent on the search results of our parent search.

Since in our use case we want to search for the products of a previously selected company, we need to add a context filter to our search, using the same Data Source as before.

Adding a Context Filter

configuring the dependant search

We start with the name of the repository $.results and then add the company name @.company.name=='').

For a better understanding of how this expression works, we could temporarily add a single company name here. Like for example: $.results[?(@.company.name=='Sporer Inc')]

This would render the raw results of all data objects of the company “Sporer Inc”.

Yet of course, we don’t just want to look up products from a singe defined company but want to have a dynamic dependancy on the respective result of our parent search.

In this case we need to add the path to the associated issue field, which is “customfield 10077”.

Thus the correct expression for a dynamic context filter will be:

$.results[?(@.company.name=='{$.issue.fields.customfield_10077}')]

Now we need to select the list repository for our child search:

adding the JSON paths to the child search

Explanation in Detail:

$.[*] to choose all items from the filtered results

$.id: the JSONPath to our id, which will again be the unique identifier.

$.name: the JSONpath to the company’s product. We add “name” as Search Field path, as we want to look up the name of the products (this doesn’t refer to the company’s name but to the name of the product). Same for the Value Field, in which the search result will be displayed later on.

The results should now be rendered correctly.

Adding additional values and styling to the search output

Let's assume that we want to have not only the product name as a result, but also their EAN numbers. In this case, we have to add that path too.

adding additional values and styling to the dependent search

Explanation in Detail:

If we add another value, in this case the EAN number, to the Value Field, we need to put the individual JSONpaths in curly backets in the Value Field as well as in the (optional) Value Label field like this:

{$.name} - {$.ean13}

We can also add styling elements to label the additional values.

For example:

{$.name} - EAN-13: {$.ean13} will later be rendered as “Product Name - EAN-13: XXXXXXXXXXXXX”

{$.name} - [EAN-13: {$.ean13}] will be rendered as “Product Name - [EAN-13: XXXXXXXXXXXXX”]

If we want to add a optional Search Template, we need to use mustache syntax, which means, we don’t need the §. as prefix but have to add another curly bracket layer to the expression. We can also use styling here. So in our case, the expression could look like this:

{{ name }} - [EAN-13: {{ ean13 }}] which would render as “Product Name - [EAN-13: XXXXXXXXXXXXX”]

(Of course, you can add whatever values you want here, maybe you want the get the color or the price instad of EAN)

This is how your results should now look like in the Jira Issue:

final result of the dependent search configuration

JavaScript errors detected

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

If this problem persists, please contact our support.