@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' >= startOfMonth(-1) and 'Date de livraison' <=endOfMonth(-1))" //If you are going to use a JIRA version => 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
@Thanos Batagiannis [Adaptavist]
Thanks!!! It works
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
issues.sum {it.getCustomValue(...)}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
created? updated? resolved?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.