How to use Insight custom field to dynamically filter a Jira custom field
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
You have a Jira custom field and you would like to have another custom field that will show objects as options based on the selection of the Jira custom field.
This is achievable with Insight custom field, especially with the Filter Issue Scope (IQL) available in the Insight custom field configuration.
Example
- You have a Jira custom field of type Select List (single choice) called Author with the configuration as shown below. You would like another custom field called Book to show only books written by the selected author in the Jira custom field.
- You have created an Insight object schema with an object type called Book, with books written by these authors as objects.
Solution
Create an Insight custom field, configure it to show up on the expected screen(s).
- Configure the Insight custom field with the following and the rest with the default option.
- Object Schema - Book
- Filter Scope (IQL) - objectType=Book
- Filter Issue Scope (IQL) - Author = ${customfield_xxxxx.name}
- If the Jira custom field allows multiple options, the filter issue scope should be changed to Author IN (${customfield_xxxxx.name${0}}). More about placeholder structure can be found at Advanced: Placeholders - Placeholder structure.
- You could also test the IQL on the object schema search to verify if it works consistently. To do so, combine the filter scope and filter issue scope IQLs and with the placeholder replaced. For instance,
- objectType=Book and Author = "Mitch Albom"
- Test it out on the Customer Portal or Jira's create issue screen. Example result:
Explanation
For this example, the Filter Issue Scope (IQL) is the main key to the solution. This scope is used because we need to filter objects based on the value available on a Jira issue field and not another Insight field, and the use of placeholders is supported.
What does the IQL, Author = ${customfield_xxxxx.name} means?
Author, on the left side of the equal sign, is one of the attributes of Book objects. The placeholder after the equal sign returns the name of the chosen value in the Author custom field, identified by the custom field ID. The ID has to be used if the field is a custom field. For system fields like issue assignee, priority, fix versions etc, refer to Advanced: Placeholders - Custom fields.