Forums

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

Why Jql parsing not working ?

Alex
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 6, 2022

Hi everyone! Please help .
The code example from the documentation does not produce a specific result for "total issue" https://scriptrunner.adaptavist.com/5.4.49-jira8/jira/recipes/misc/running-a-jql-query.html

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()

// edit this query to suit

def query = jqlQueryParser.parseQuery("project = JRA AND assignee = currentUser()" )

def search = searchService.search(user, query, PagerFilter.getUnlimitedFilter())

log.debug("Total issues: ${search.total}")

search.results.each {documentIssue ->

    log.debug(documentIssue.key)

    // if you need a mutable issue you can do:

    def issue = issueManager.getIssueObject(documentIssue.id)

    // do something to the issue

    log.debug(issue.summary)
}

1 answer

0 votes
Martin Bayer [MoroSystems, s.r.o.]
Community Champion
September 6, 2022

Hi @Alex can you share log output, please?

Martin Bayer [MoroSystems, s.r.o.]
Community Champion
September 6, 2022

I can see, that JQL query is exactly the same as mentioned in the snippet. Do you really have project with key = JRA created on your Jira instance?

Alex
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2022

Hi @Martin Bayer [MoroSystems, s.r.o.] !

the result I expect is "total : 2"

in my console log output :

efwefwEF.png

Martin Bayer [MoroSystems, s.r.o.]
Community Champion
September 8, 2022

Hi @Alex I think the problem is in your logging level. Try to change

  • log.debug

TO

  • log.error

Otherwise you need to set logging level on the beginning of the script

  • log.setLevel(Level.DEBUG)

The results will be displayed on Logs tab

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events