Forums

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

Jira filter query count to scritrunner script

Ramaiah Pendli July 15, 2016

Hi,

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

1 vote
Answer accepted
Thanos Batagiannis [Adaptavist]
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.
July 15, 2016

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) }
    }
}
}
Ramaiah Pendli July 15, 2016

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
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events