Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,364,032
Community Members
 
Community Events
168
Community Groups

Why Jql parsing not working ?

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

Hi @Oliver Smith can you share log output, please?

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?

Hi @Martin Bayer _MoroSystems_ s_r_o__ !

the result I expect is "total : 2"

in my console log output :

efwefwEF.png

Hi @Oliver Smith 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

Atlassian Community Events