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
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?
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.SearchServiceimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.search.SearchExceptionimport com.atlassian.jira.web.bean.PagerFilterfinal jqlSearch = "assignee = currentUser() and status = \"IN PRODUCTION\""final maxIssues = 3def user = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef 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.resultsreturn 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?
scrin
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?
It looks like you're new here. Sign in or register to get started.