Jira filter query count to scritrunner script


can some one help me out how to write a scriptrunner script for output of total issues to below filter query.

project = RD AND issuetype = Ticket AND status in (Reopened, "In Progress", Open, Accepted) AND component = SCI



1 answer

1 accepted

Hi Ramaiah

Try this one

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

def jql = "project = RD AND issuetype = Ticket AND status in (Reopened, 'In Progress', Open, Accepted) AND component = SCI"
def issuesFromJQL = getIssuesFromJql(jql)

def getIssuesFromJql(String jql) {
    def adminUser = ComponentAccessor.getUserManager().getUserByKey("admin") //todo this should be an admin user
    def searchService = ComponentAccessor.getComponent(SearchService)
    def issueManager = ComponentAccessor.getIssueManager()

    SearchService.ParseResult parseResult =  searchService.parseQuery(adminUser, jql)
    if (parseResult.isValid()) {
        def searchResult = searchService.search(adminUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
        return searchResult.issues.collect { issueManager.getIssueObject(it.id) }

Hi Thanos,

Can we get the total number of issue with number(ex: 10).

if 11th  issue created it should trigger notification email to the user to say some message like "it will be delay to resolve the issue".

and can i put this script in Script Listeners for send out an email when new issue created condition. 




Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

504 views 1 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you