Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Filter an asset Custom Field with AQL in issue create screen

reza rouhafza
Contributor
September 28, 2025

Hi there.

It’s a simple and common requirement, and I haven’t found a way to implement it in Jira.

I have an object type called “Employee” with approximately 2,000 objects.

I have an Asset custom field called “Employee_CF” that I want to populate in Jira Service Management (JSM) with multiple Employee objects. The problem: I want to query employees by various attributes to return a subset that fits the issue context. For example, I want to add employees who are female and part of Team A. There are several options in Jira:

  • “Allow selecting all objects” isn’t suitable, because I don’t want all employees added to an issue.

  • “Filter Issue Scope (AQL)” doesn’t suit my needs either: it effectively requires adding all Employee attributes as driver fields on the form. If any of them is left empty, the Asset field returns no results (placeholders don’t resolve when a driver field is empty).

Example
Object Type: Employee
Attributes: {gender, team, role, year of birth, technical expertise, status}

  • I want to select all employees who were born in 1995.

  • I want to select all employees in “Team A” who are male and currently active.

  • I want to select Bill without specifying all of his other attributes.

Question: What is the recommended approach to achieve optional, attribute-based filtering for an Asset field in JSM?

1 answer

0 votes
Jayesh Raghuvanshi
Contributor
September 29, 2025

@reza rouhafza 

That is an important distinction. While the underlying principle remains the same, Jira Data Center (DC) has slightly different Smart Value functions and may have different custom field behaviors compared to Jira Cloud.

However, the general strategy of using a hidden AQL Driver field populated by Jira Automation is still the most robust solution for achieving optional, attribute-based filtering in Assets on Jira DC.

Here is the approach tailored for Jira Data Center, leveraging conditional Smart Values to construct a valid AQL query.

Recommended Solution for Jira Data Center
The goal is to create a dynamic, syntactically correct AQL string in a hidden field, which the visible Assets field then uses as its filter. This ensures that empty filter fields do not break the AQL query.

1. Setup the Custom Fields
You will create three types of fields: the final output field, and several visible "driver" fields.

Field Name Type Purpose Configuration
Employee_CF (Your Asset Field) Assets Object The field for the agent to select the final objects. Filter Work Scope (AQL): objectType = "Employee" AND object in (${AQL Query Driver})
AQL Query Driver Single Line Text Hidden from agents. This field stores the dynamic AQL query string. Ensure it is on the relevant screens/request forms.
Gender Selector Select List / Text Visible to agents. Used to capture the optional filter value. Map to the relevant screens.
Team Selector Select List / Text Visible to agents. Used to capture the optional filter value. Map to the relevant screens.

Export to Sheets
2. Configure the Jira Automation Rule
The automation rule will monitor the user's input fields and assemble the AQL into the hidden AQL Query Driver field.

Component Setting Notes
Trigger Field value changed Trigger on changes to the visible filter fields (e.g., Gender Selector, Team Selector, etc.).
Action Edit Issue Update the hidden AQL Query Driver field with the dynamic query.

Export to Sheets
The Dynamic AQL Smart Value (for the Edit Issue Action)
The core logic uses the {{#if}} conditional Smart Value available in Jira Automation to check if a field has a value before adding it to the AQL string.

To populate the AQL Query Driver field, use a Smart Value similar to this:

JSON

{
"fields": {
"AQL Query Driver": "objectType = \"Employee\" AND Status = \"Active\"
{{#if issue.customfield_12345.value}} AND Team = \"{{issue.customfield_12345.value}}\"{{/if}}
{{#if issue.customfield_54321.value}} AND Gender = \"{{issue.customfield_54321.value}}\"{{/if}}"
}
}
Custom Field IDs: In DC, it is best practice to use the raw Custom Field ID (e.g., customfield_12345) instead of the field name in Smart Values for reliability.

The Base Query: You start with any mandatory filters, such as objectType = "Employee" AND Status = "Active".

Optional Filters: The {{#if}} block ensures that if a field is empty (e.g., the agent did not select a gender), the Smart Value simply outputs nothing, and the AND Gender = "..." clause is omitted entirely.

Line Breaks: Line breaks are included above for readability, but you should enter this as a single, continuous string in the automation editor.

Handling the "Search by Name Only" Requirement
To allow an agent to search by a specific employee's name (e.g., "Bill") without having to select the team or gender, you need to introduce an OR logic into your AQL construction.

Add a Name Selector text field to the issue screen.

Update the Smart Value logic:

JSON

{
"fields": {
"AQL Query Driver": "objectType = \"Employee\"
{{#if issue.Name_Selector.value}}
(Name = \"{{issue.Name_Selector.value}}\")
{{else}}
(Status = \"Active\"
{{#if issue.Team_Selector.value}} AND Team = \"{{issue.Team_Selector.value}}\"{{/if}}
{{#if issue.Gender_Selector.value}} AND Gender = \"{{issue.Gender_Selector.value}}\"{{/if}})
{{/if}}"
}
}
The Logic: This example uses an {{#if Name Selector}} / {{else}} structure to choose between two completely different AQL paths:

Path 1 (Name Entered): If the agent enters a name, the AQL is simply objectType = "Employee" (Name = "Bill"). It ignores all other filters.

Path 2 (Name Empty): If the name is empty, it executes the {{else}} block, which builds the compound filter using Team, Gender, etc.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events