Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:52:18+00:00 2026-06-15T00:52:18+00:00

I am struggling with a JQL query. We have a custom field called ‘Build

  • 0

I am struggling with a JQL query.

We have a custom field called ‘Build Reported’ which is a text field. It has values like ‘4.7.323H’, ‘5.1.123L’, ‘3.1.456E’, etc.

I need to write a simple query that will give me all issues reported after the user-specified version.

JQL function prototype: searchIssues(‘Build Integrated’, ‘>’, ‘4.7.323B’)

To do this, I am firing a JQL Query that gives me the Build Reported for all the issues, I then iterate through each issue and perform a char-by-char comparison to determine if the Build Reported version of the current issue is greater than the one specified by the user. This seems to take too long to execute since I have to retrieve all the issues from jira database.

Is there a faster way to achieve this? Here is what I have so far:

// Get all the arguments
java.util.List args = operand.getArgs();
CustomField cf = customFieldManager.getCustomFieldObjectByName((String)args.get(0));
Long cfID = cf.getIdAsLong();
String operator = (String)args.get(1);
String userVersion = (String)args.get(2);
String jiraVersion = "";

java.util.List issues;
Iterator issuesIterator;
Issue issue;

issues = getAllIssues(user, interestedInVersion, cfID);
issuesIterator = issues.iterator();

// Iterate over all the issues
while(issuesIterator.hasNext())
{
    issue = (Issue)issuesIterator.next();

    // Get the Build reported value
    jiraVersion = (String)issue.getCustomFieldValue(cf);

    if(jiraVersion != null &&
       !jiraVersion.equals(""))
    {
        // Compare user-specified version to the one retrieved from database
        if(compareVersions(jiraVersion, userVersion, operator))
        {
            // Add the issue to the result set
            literals.add(new QueryLiteral(operand, issue.getId()));
        }
    }
}

// cfID is the ID for the custom field Build Reported
private java.util.List getAllIssues(User user, Long cfID) throws SearchException, ParseException
{
    JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
    builder.where().project("SDEV").and().customField(cfID).isNotEmpty();
    Query query = builder.buildQuery();
    SearchResults results = searchService.search(user, query, PagerFilter.getUnlimitedFilter());
    return results.getIssues();
}

Please note that I do not have any other filters that I could use for the JQL Query Builder to help me reduce the size of the result set.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:52:19+00:00Added an answer on June 15, 2026 at 12:52 am

    I found an alternative to the issue I described in my question. Instead of using JQL, I ended up firing a direct SELECT and this turned out to be way quicker. The function below is a part of the JQL Plugin. Here is the code:

    This is what I ended up doing:

    public java.util.List getValues(@NotNull QueryCreationContext queryCreationContext, @NotNull FunctionOperand operand, @NotNull TerminalClause terminalClause)
    {
        try
        {
            // User
            User user = queryCreationContext.getUser();
    
            // Args
            java.util.List args = operand.getArgs();
            CustomField cf = customFieldManager.getCustomFieldObjectByName((String)args.get(0));
            Long cfID = cf.getIdAsLong();
            String operator = (String)args.get(1);
            String userVersion = (String)args.get(2);
    
            // Locals
            java.util.List literals = new java.util.LinkedList();
            MutableIssue issue = null;
            String issueId = "";
            String jiraVersion = "";
    
            // DB
            Connection conn = null;
            String url = "jdbc:jtds:sqlserver://*****:*****/jiradb";
            String driver = "net.sourceforge.jtds.jdbc.Driver";
            String userName = "*******";
            String password = "*******";
            String sqlQuery = null;
            Statement statement = null;
            ResultSet resultSet = null;
    
            Class.forName(driver).newInstance();
            conn = DriverManager.getConnection(url, userName, password);
    
            // Get all the issues that has the custom field set
            sqlQuery = " SELECT t2.id AS IssueId, t1.stringvalue AS JiraVersion " + "\n" +
                            " FROM   jiradb.jiraschema.customfieldvalue t1 " + "\n" +
                            " INNER JOIN jiradb.jiraschema.jiraissue t2 " + "\n" +
                            " ON     t1.issue = t2.id " + "\n" +
                            " WHERE  t1.customfield = " + Long.toString(cfID) + " " + "\n" +
                            " AND    t1.stringvalue IS NOT NULL " + "\n" +
                            " AND    t1.stringvalue != '' " + "\n" +
                            " AND    t2.pkey LIKE 'SDEV-%' ";
    
            // Iterate over the result set
            statement = conn.createStatement();
            resultSet = statement.executeQuery(sqlQuery);
            while (resultSet.next()) 
            {  
                issueId = resultSet.getString("IssueId");  
                jiraVersion = resultSet.getString("JiraVersion");
    
                // Compare the version from jira with the user provided version
                // This is my own function that does char-by-char comparison
                if(compareVersions(jiraVersion, userVersion, operator))
                {
                    // Get the issue object to add to the result
                    issue = ComponentManager.getInstance().getIssueManager().getIssueObject(Long.parseLong(issueId));
    
                    // Add the issue to the result
                    literals.add(new QueryLiteral(operand, issue.getId()));
                }
            }
    
            // Return all the matching issues here
            return literals;
        }
        catch(Exception e)
        {
            // Exception handling
        }
    
        return null;
    }
    

    And this is how the plugin is used:

    issue in searchIssues('Build Reported', '>', '5.1.104');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam struggling with NHibernate and its lazyload. I have a structure which I simplified
Struggling with a SQL query of mine here. I have a table: APPS(id, game)
Im struggling a bit with the UIkeyboard, I have a datePicker, IntervalPicker some custom
Struggling getting a query to work…….. I have two tables:- tbl.candidates: candidate_id agency_business_unit_id tbl.candidate_employment_tracker
Struggling to work this one out; I have a (Tomcat6 'Context.xml') default document, which
Struggling with a bit of a mystery regarding a ghost like JESSIONID Cookie. I'm
Struggling with styling the mouse over for a button ... I have managed to
Im struggling with this one. I have a list of items and on a
been struggling with an issue now for a day or two. I have an
Struggling with the following problem. I have an attribute that defines the name of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.