I have a Scriptrunner custom single issue picker field "Master" which is used on selected custom issue types to allow users to select from a subset of Epics. This is used for a slightly different purpose than the built-in Epic field, and I need to have both.
When using JQL to search for issues, if I use
issueFunction in issuePickerField('Master')
I get a list of all of the issues where the user has selected something in the Master field. What I want is to get a list of the issues (Epics) that were selected in that field (like what "epicsOf" returns, except this would be for the Master field, rather than the built-in Epic fields).
Am I missing something? Is there a way to do this with JQL? (Based on what I read in the Scriptrunner docs, I do not have the skill / knowledge / tools to create my own JQL custom function.)
Unless I'm misunderstanding something, I don't think the existing function allows that.
I would recommend making a feature request to get the reverse of the current issuePickerField function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ran into the same problem. Ended up with a custom "epicsOf"-like JQL-function:
package com.onresolve.jira.groovy.jql
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.jql.query.LuceneQueryBuilder
import com.atlassian.jira.jql.query.QueryCreationContext
import com.atlassian.jira.jql.validator.NumberOfArgumentsValidator
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.util.MessageSet
import com.atlassian.query.clause.TerminalClause
import com.atlassian.query.operand.FunctionOperand
import org.apache.lucene.search.Query
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.util.MessageSetImpl
import com.atlassian.jira.security.JiraAuthenticationContext
import org.apache.lucene.search.BooleanQuery
import com.atlassian.jira.issue.Issue
import org.apache.lucene.search.TermQuery
import org.apache.lucene.index.Term
import org.apache.lucene.search.BooleanClause
import java.text.MessageFormat
class presalesOf extends AbstractScriptedJqlFunction implements JqlQueryFunction {
@Override
String getDescription() {
"Get Presales of issues fetched from query"
}
@Override
List<Map> getArguments() {
[
[
description: "Subquery",
optional : false,
]
]
}
@Override
String getFunctionName() {
"presalesOf"
}
@Override
Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) {
JiraAuthenticationContext context = ComponentAccessor.getJiraAuthenticationContext()
ApplicationUser applicationUser = context.getLoggedInUser()
BooleanQuery.Builder boolQueryBuilder = new BooleanQuery.Builder()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cFieldPresale = customFieldManager.getCustomFieldObjectsByName("Presale").getAt(0)
String queryPrefix = "((Presale is not Empty AND project != PRESALE) OR (FieldName is not Empty AND project = PRESALE AND issueType != Epic))"
String subquery = "${queryPrefix} AND ${operand.args[0]}"
issues = getIssues(subquery, applicationUser)
Collection<Issue> issuesPresales = (issues.findAll { it }*.getCustomFieldValue(cFieldPresale)) as Collection<Issue>
issuesPresales = issuesPresales?.unique()
issuesPresales.each {Issue issue ->
try {
boolQueryBuilder.add(new TermQuery(new Term("issue_id", issue.id as String)), BooleanClause.Occur.SHOULD)
} catch(NullPointerException NPE) {
}
}
return boolQueryBuilder.build()
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am looking for the same solution
have you found a solution for that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No solution yet. It is sitting with Atlassian as a new feature request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You won't get any traction with an Atlassian feature request.
This is a scriptrunner JQL functionality.
You need to ask Adaptavist for this: https://productsupport.adaptavist.com/servicedesk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Apologies, teach me for responding too early my time. I meant that it's with Adaptavist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.