Would love to add a time function to my Groovy script? Help?

Hey all,


Been trying to figure out how to modify this script to make it so that i'm able to add a date range to this Script, or a "since" field where i can add a date – running it as is we are returning too many results:

package eventim.scripts

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.web.bean.PagerFilter
jqlQuery = 'project = DEV'
fromProject = 'PUP'
result = ''

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

getFilterResult(jqlQuery,log).each{ Issue issue ->
    oldKeys = changeHistoryManager.getPreviousIssueKeys(issue.id)
        result += "$it -> ${issue.key}\n"
return result

List<Issue> getFilterResult(String jqlSearch, log) {
    def searchService = ComponentAccessor.getComponent(SearchService.class);
    def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
    List<Issue> issues = null

    def parseResult =  searchService.parseQuery(user, jqlSearch);
    if (parseResult.isValid()) {
        def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
        issues = searchResult.issues
    } else {
        log.error("Invalid JQL: " + jqlSearch);
    return issues

1 answer

Change your jql to include your date ranges... replace the dates with the date range you are looking to search for.


jqlQuery = 'project = DEV and resolved >= 2015-04-01 AND resolved <= 2015-04-12'
fromProject = 'PUP'
result = ''

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

449 views 7 5
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