I have a project where we manage release, now there are over 500 people using that project and sometimes people from the same team can raise issue with the same details.
I want to stop people from creating another issue which contains the same "Component" and "Region" only for a specific fix version. For every single component only 1 issue should be raised from a particular region I do not want two issues for a component with same region values.
Can I use the Create transition validator to restrict this and if yes then can someone please help me with the jql or groovy script.
Here is an example of running a JQL query within a Groovy script, so perhaps you can leverage this in a validator.
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter
String jqlSearch = "project = jadmin" //modify this to check for a component and region for a specific fix version
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
UserUtil userUtil = ComponentAccessor.getUserUtil()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()
List<MutableIssue> issues = null
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
SearchResults searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.getResults().collect {issueManager.getIssueObject(it.id)}
//if issues count is > 0, then fail validation
} else {
log.error("Invalid JQL: " + jqlSearch);
}
Hi @Payne
So like there are more than 37 components and 4 regions, is there any way to write the code dynamically instead of mentioning all the components for all regions that too for a specific fix version
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm thinking you can define the jqlSearch variable to be something like this:
jqlSearch = "component = " + issue.component + " and region = " + issue.region + " and fixVersion = " + issue.fixVersion;
If that returns 1 or more issues, then fail validation.
I don't know offhand if region is a system field or a custom field; if custom, you will need to get it differently than issue.region. You may also need to wrap the data elements in quotes to handle embedded spaces, e.g. "component = " + "\"" + issue.component + "\""
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.