Skip to main content
Skip table of contents

Filter query results using JSONPath

Elements Connect Cloud lets you fetch data from any JSON-based REST API to populate your connected fields. At the heart of this integration is JSONPath, a lightweight query language for selecting and filtering parts of a JSON document.

This tutorial shows how to use basic JSONPath expressions to filter connected field results when multiple custom field dependencies are in play. We’ll create a project picker, an issue type picker that depends on it, and a final field that shows issues matching both.

For more details on JSONPath in Elements Connect cloud, see JSON Path explained

In this tutorial we'll use the Jira REST API as a datasource.

Filtering by issue type using JSONPath, as shown in this example, is not the most efficient approach when working with the Jira REST API. The recommended method is to include the issue type as a parameter directly in the query (e.g., using JQL in the request URL) to reduce payload size and improve performance.

However, we've used this example deliberately to illustrate how JSONPath filtering works in practice. This technique is especially useful for data sources that do not support URL-based filtering, where post-processing the response is the only option.

Step 1 – Parent field setup: List projects of a Jira instance

First, create a simple “Object” custom field to serve as a parent, using the configuration shown below. This field will list the projects in your Jira instance.

image-20250702-072543.png
image-20250702-072640.png

By using $, we don’t filter out any results; we retain the entire JSON and display the options according to the following templates.

image-20250702-073049.png

Step 2 – Child custom field setup: List issue types for selected project

Next, we’ll create a second “Snapshot” custom field that depends on the one we just made (customfield_12002). This field will list the issue types available in the selected project from our parent custom field.

image-20250702-073407.png

We’ve enabled FreeMarker to support dynamic dependencies—just adjust the path to match your parent custom field’s ID. There’s no need for another JSONPath filter here; you can continue using $ and use ${row.name} as your template.

Step 3 – Grandchild field: List issues filtered by both project and issue type

Next, we’ll create our “grandchild” field: a multi-select Snapshot custom field that depends on both the project field (customfield_12002) and the issue-type field (customfield_12004). Here’s the JSONPath expression you’ll use:

image-20250702-074140.png
View the configuration
CODE
<#assign jql="id = -1">
<#if issue.customfield_12002?has_content && issue.customfield_12002.value?has_content>
  <#assign projects = issue.customfield_12002.value>
  <#assign jql = "project IN (${projects})">
</#if>

/search/jql?maxResults=100&fields=*all&jql=${jql?url}

Here, we again use FreeMarker to enable dynamic dependencies. This query depends on the first custom field we created and retrieves all issues in the selected project. We then apply a JSONPath filter to those results, using the issue type chosen in our second custom field.

image-20250702-075356.png
View the configuration
CODE
$.issues[?(@.fields.issuetype.name == "${issue.customfield_12004}")]

We only select issues whose issue type matches the value chosen in customfield_12004. Use ${row.key} as your template. In this example, we’ve only used JSONPath in the “Data in API response” field, but you can combine it with FreeMarker for even more flexibility.

Then in the issue view we have:

image-20250702-075805.png

JavaScript errors detected

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

If this problem persists, please contact our support.