Greetings
I am needing assistance creating a scripted field to return the results of children issues from our roadmap plans, basically the inverse of "Parent Link" field. We can query this via JQL and it returns the correct results for a given issue key using the portfolioChildrenOf issueFunction (ScriptRunner JQL function).
Example JQL: issueFunction in portfolioChildrenOf("issue in (AJJ-322)")
This returns children issues (epics in this case) of the issue key which is a feature, above epic in our plan hierarchy.
Below is the script code I have tried to implement but it is not returning any results ; its throwing what appears to be a JQL parsing error (also listed below). I am hoping someone can assist or advise what might be happening in my script or aid with a solution. Thanks.
SCRIPTED FIELD CODE:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
def issueManager = ComponentAccessor.getIssueManager()
def searchService = ComponentAccessor.getComponent(SearchService.class)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def issue = issueManager.getIssueObject(issue.key)
def jqlQuery = jqlQueryParser.parseQuery("issueFunction in portfolioChildrenOf('" + issue.key + "')")
def searchResults = searchService.search(user, jqlQuery, PagerFilter.getUnlimitedFilter())
return searchResults.getResults().size()
ERROR FROM LOGS:
2024-03-22T15:55:07,087 ERROR [jql.ScriptedFunctionClauseFactory]: Error in ScriptRunner JQL function clause {issueFunction in portfolioChildrenOf(AJJ-322)} com.atlassian.jira.jql.parser.JqlParseException: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException: NoViableAltException(-1@[]) at com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseClause(DefaultJqlQueryParser.java:110) ~[classes/:?] at com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseQuery(DefaultJqlQueryParser.java:33) ~[classes/:?] at com.atlassian.jira.jql.parser.JqlQueryParser$parseQuery$14.call(Unknown Source) ~[?:?] at com.onresolve.jira.groovy.jql.AbstractScriptedJqlFunction.search(AbstractScriptedJqlFunction.groovy:211) ~[plugin.4110092473777456710.groovyrunner-8.22.0.jar:8.22.0] at com.onresolve.jira.groovy.jql.AbstractScriptedJqlFunction$search$0.callCurrent(Unknown Source) ~[?:?] at com.onresolve.jira.groovy.jql.relations.portfolio.PortfolioChildrenOf.getQuery(PortfolioChildrenOf.groovy:28) ~[plugin.4110092473777456710.groovyrunner-8.22.0.jar:8.22.0] at com.onresolve.jira.groovy.jql.JqlQueryFunction$getQuery.call(Unknown Source) ~[?:?] at com.onresolve.jira.groovy.jql.ScriptedJqlFunction.getQuery(ScriptedJqlFunction.groovy:135) ~[plugin.4110092473777456710.groovyrunner-8.22.0.jar:8.22.0] at com.onresolve.jira.groovy.jql.ScriptedJqlFunction$getQuery.call(Unknown Source) ~[?:?] at com.onresolve.jira.groovy.jql.ScriptedFunctionClauseFactory.getQuery(ScriptedFunctionClauseFactory.groovy:110) ~[plugin.4110092473777456710.groovyrunner-8.22.0.jar:8.22.0] Caused by: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException: NoViableAltException(-1@[]) at com.atlassian.jira.jql.parser.antlr.JqlParser.reportError(JqlParser.java:203) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.operator(JqlParser.java:1362) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.terminalClause(JqlParser.java:645) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.notClause(JqlParser.java:555) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.andClause(JqlParser.java:432) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.orClause(JqlParser.java:366) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.clause(JqlParser.java:328) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.query(JqlParser.java:237) ~[classes/:?] at com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseClause(DefaultJqlQueryParser.java:103) ~[classes/:?] ... 9 more Caused by: org.antlr.runtime.NoViableAltException at com.atlassian.jira.jql.parser.antlr.JqlParser.operator(JqlParser.java:1192) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.terminalClause(JqlParser.java:645) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.notClause(JqlParser.java:555) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.andClause(JqlParser.java:432) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.orClause(JqlParser.java:366) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.clause(JqlParser.java:328) ~[classes/:?] at com.atlassian.jira.jql.parser.antlr.JqlParser.query(JqlParser.java:237) ~[classes/:?] at com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseClause(DefaultJqlQueryParser.java:103) ~[classes/:?] ... 9 more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.