You need a validator script to count the number of search tasks
(status = "IN PRODUCTION" AND assignee in (currentUser ()))
I want to check the condition for no more than 3 tasks
This ought to work; it will return true, and thus pass validation, if the current user has 3 or fewer "In Production" issues assigned to him. Otherwise it will return false and fail validation.
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
final jqlSearch = "assignee = currentUser() and status = \"IN PRODUCTION\""
final maxIssues = 3
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def searchService = ComponentAccessor.getComponentOfType(SearchService)
def parseResult = searchService.parseQuery(user, jqlSearch)
if (!parseResult.isValid()) {
log.error('Invalid query')
return null
}
try {
def results = searchService.search(user, parseResult.query, PagerFilter.unlimitedFilter)
def issues = results.results
return issues.size() <= maxIssues
} catch (SearchException e) {
e.printStackTrace()
null
}
Hi, thanks a lot for the validator script. He looks like a worker. I paste it into the Custom script validator form and it doesn't work.
What am I doing wrong?
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.
What do you mean by "it doesn't work"? Do you receive an error, or is it not stopping the issue from being assigned to someone with > assigned tasks?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It not stopping the issue from being assigned to someone with> assigned tasks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You ARE changing the assignee during a transition, correct? This validator will not prevent someone from simply changing the assignee.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Viewer I will need better description of your use case. Could you describe it in steps? You are kind of mixing Validators and Conditions (which have different meaning in Jira). So can you describe what/when should be diplayed?
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.