We need to get list of distinct assignees from a filter results, using groovy or rest query.
Any ideas much appreciated. Thanks.
Below script returns distinct assignees but twice. And there maybe better version to this,
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Level
import org.apache.log4j.Logger
def appUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def linkManager = ComponentAccessor.getIssueLinkManager()
def searchService = ComponentAccessor.getComponent(SearchService.class)
def issueManager = ComponentAccessor.getIssueManager()
//def log = Logger.getLogger("Jira Log")
log.setLevel(Level.DEBUG)
def jqlSearch = "project = XYZ AND issuetype = 'Request' AND assignee in (membersOf(XYZ_Users)) AND status not in (Closed, Cancelled) AND updatedDate <= -7D"
SearchService.ParseResult parseResult = searchService.parseQuery(appUser, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(appUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def issues = searchResult.results.collect {issueManager.getIssueObject(it.id)}
issues.assignee.unique().each { issue ->
}
}
else{
log.error("Invalid JQL :" + jqlSearch)
}
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.