Filter based on multiple criteria by using a non-Boolean JQL function

Filter based on multiple criteria by using a non-Boolean JQL function

Problem

You want to filter issues based on two or more criteria. However, this can’t be achieved by using the typical boolean operators in standard JQL.

Solution

Create a custom SIL script that counts how many criteria each issue meets and returns issues where at least 2 out of 5 possible criteria are true. The script loops through all issues in a project, checks each condition, and uses a counter to track matches.

Script

string [] keys = selectIssues("project= " + argv[0]); string [] ret; for(string k in keys){ int criteriaCount = 0; if(arrayElementExists(%k%.labels, "criteria")) { criteriaCount ++; } if(%k%.assignee == %k%.reporter) { criteriaCount ++; } if(isNull(%k%.desc)) { criteriaCount ++; } if(arrayElementExists(%k%.components, "JIRA")) { criteriaCount ++; } if(%k%.priority == "Major") { criteriaCount ++; } if(criteriaCount >=2) { ret += k; } } return ret;

Implementation steps

  1. Create the SIL script using the code provided above.

  2. Customize the criteria by modifying the conditions to match your specific requirements:

    • Replace "criteria" with your desired label.

    • Replace "JIRA" with your component name.

    • Replace "Major" with your priority level.

    • Adjust the minimum criteria count (currently set to 2).

  3. Save the script as silJQL_FindTwoOrMoreCriteria.sil.

  4. Use the script in JQL queries as shown in the example below.

For detailed explanation, watch this video:

Example usage (JQL query)

This query returns all issues in a project named PROJ where at least two of the five defined criteria are met:

  • Has a label called criteria;

  • Assignee equals reporter;

  • Description is null/empty;

  • Contains component JIRA;

  • Priority is set to Major.

key in silJQLList("silJQL_FindTwoOrMoreCriteria.sil", PROJ)

Need support? Create a request with our support team.

Copyright © 2005 - 2025 Appfire | All rights reserved.