Get issues of a porject by date

Hi, 

Could somebody translate my sentence in a groovy script? 

 

get issues of a project for a particular period? 

 

 

Thanks

5 answers

This widget could not be displayed.

Hi Robi,

Not sure what you are trying to do here but you can get all issues between two dates in JQL using a query similar to below.

project = "Kristians Dev Project" and createdDate >= startOfMonth() and createdDate <= endOfMonth()

I hope this helps

Kristian

And in case you want  to use the - returned from a JQL issues - in a script

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter
 
def issueManager = ComponentAccessor.getIssueManager()
def searchService = ComponentAccessor.getComponent(SearchService)
def jql = "project = 'Kristians Dev Project' and createdDate >= startOfMonth() and createdDate <= endOfMonth()"
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issues = []
 
SearchService.ParseResult parseResult =  searchService.parseQuery(user, jql)
if (parseResult.isValid()) {
    def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
    issues = searchResult.issues.collect { issueManager.getIssueObject(it.id) }
}
//an array with the issues returned from the JQL
return issues
This widget could not be displayed.

created? updated? resolved?

This widget could not be displayed.

due date

This widget could not be displayed.

@Thanos Batagiannis [Adaptavist] 

Thanks!!! It works smile

I am getting all the issues of my JQL request. 

Now, can I sum all the values of a custom field from all the issues? 

 

 

 

issues.sum {it.getCustomValue(...)}

I have as result "No return value". 

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

def issueManager = ComponentAccessor.getIssueManager()
def searchService = ComponentAccessor.getComponent(SearchService)
def jql = "project = 'AISC - Suivi des demandes' and ('Date de livraison' >= startOfMonth(-1) and 'Date de livraison' <=endOfMonth(-1))"
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issues = []

SearchService.ParseResult parseResult = searchService.parseQuery(user, jql)
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
// issues = searchResult.issues.collect { issueManager.getIssueObject(it.id) }
issues = issues.sum {it.getCustomValue("Temps d'intervention")}
}
//an array with the issues returned from the JQL
return issues

 

This widget could not be displayed.

@Thanos Batagiannis [Adaptavist] 

@Jamie Echlin (Adaptavist)

 

Hello, 

 

I have found another script doing exactly the same thing, and the sum of spent time:

 

 

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

def jqlSearch = "project = 'AISC - Suivi des demandes' and ('Date de livraison' &gt;= startOfMonth(-1) and 'Date de livraison' &lt;=endOfMonth(-1))"
//If you are going to use a JIRA version =&gt; 7 then you should get the ApplicationUser instead of User, to do that remove the .directoryUser
def user = ComponentAccessor.getJiraAuthenticationContext().getUser().directoryUser
def searchService = ComponentAccessor.getComponentOfType(SearchService.class)
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)

def value = 0
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def myCustomField = customFieldManager.getCustomFieldObjectByName("Temps d'intervention")

if (parseResult.isValid()) {
try {
def results = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def issues = results.getIssues()
issues.each {
if (it.getCustomFieldValue(myCustomField))
value += it.getCustomFieldValue(myCustomField).toInteger()

}
} catch (SearchException e) {
e.printStackTrace()
}
} else {
log.warn("Invalid query")
return null
}

return value

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

534 views 3 19
Read article

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