Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

JQL Query in script does not run after modifying a field Edited

Hello community,

I need some advice u help with this problem I have.

We create a script that basically what it does is capture the id of a relay assigned in a custom field called "Cell / Release" through a JQL Query in the script:

def jqlQuery = "fixVersion in ($ {issue.getCustomFieldValue (cf1)})" --- ⇒ the value is saved as “id” and not with the version name.

Then the script goes through the issues within the release, and validates some conditions to move forward with the transition.

The code worked fine until it asked us to change the field type of the "Cell / Release" field to the "Multi selection" type.

When testing what values ​​the field is returning to me when selecting more than one release, it returns the "id" separated by "," which is fine, since the JQL should look something like this:

def jqlQuery = "fixVersion in (13005,13006)", executing from the script console the jql is executed correctly and we enter the values ​​directly. But when taking the code to the validation of my workflow, when executing I get the following error:

2020-12-14 11: 04: 25,887 ERROR [workflow.ScriptWorkflowFunction]: ******************************** * *********************************************** **
2020-12-14 11: 04: 25,887 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on problem: IMP-74, actionId: 11, file: <script on line>
com.atlassian.jira.jql.parser.JqlParseException: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException: NoViableAltException (32 @ [])
                in com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseClause (
                in com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseQuery (
                in com.atlassian.jira.jql.parser.JqlQueryParser $ (Unknown source)
                in Script236.findIssues (Script236.groovy: 33)
                in (Script236.groovy: 121)
Caused by: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException: NoViableAltException (32 @ [])

Here is the complete Script:

import com.atlassian.jira.component.ComponentAccessor;

import com.atlassian.jira.jql.parser.JqlQueryParser;


import com.atlassian.jira.web.bean.PagerFilter;

import com.atlassian.jira.issue.fields.CustomField

import com.atlassian.jira.issue.fields.config.FieldConfig

import com.atlassian.jira.issue.context.IssueContextImpl

import com.atlassian.jira.issue.customfields.manager.OptionsManager

import com.atlassian.jira.issue.customfields.option.Options

import com.atlassian.jira.issue.customfields.option.Option

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.ModifiedValue

import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

import org.apache.log4j.Level

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.MutableIssue

import org.apache.log4j.Logger

import com.atlassian.jira.issue.customfields.option.LazyLoadedOption;

import com.atlassian.jira.issue.IssueManager

import com.opensymphony.workflow.InvalidInputException

import com.onresolve.scriptrunner.runner.util.UserMessageUtil


        def log = Logger.getLogger("com.acme.workflows")


        def issue = issue as MutableIssue

        Long issueId = issue.getId()


        boolean findIssues(String jqlQuery) {

        def issueManager = ComponentAccessor.issueManager

        def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()

        def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)

        def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)

        def query = jqlQueryParser.parseQuery(jqlQuery)

        def results =, user, PagerFilter.unlimitedFilter)


        def customFieldManager = ComponentAccessor.getCustomFieldManager()

        def cf2 = customFieldManager.getCustomFieldObjects(issue).find { == "Revisión Seguridad (QA Técnico)"}

        def cf2val = issue.getCustomFieldValue(cf2)


        def cf3 = customFieldManager.getCustomFieldObjects(issue).find { == "Revisión Rendimiento"}

        def cf3val = issue.getCustomFieldValue(cf3)


        int trueCount = 0;

        int trueCount2 =0;




                if (cf2val==null || (((LazyLoadedOption)cf2val).getValue()=="Rechazado"))




                    invalidInputException = new InvalidInputException(trueCount)   

                    invalidInputException = new InvalidInputException("Revision de Seguridad 'Rechazado' o pendiente de completar, favor comunicarse con el equipo de seguridad para resolver esta revisión")



                else if ((cf3val==null || (((LazyLoadedOption)cf3val).getValue()=="No")))




                    invalidInputException = new InvalidInputException("Revision de rendimiento 'Rechazado' o 'No' o pendiente de completar, favor comunicarse con el equipo de rendimiento para resolver esta revisión")





                else if((((LazyLoadedOption)cf2val).getValue()=="Aprobado") || (((LazyLoadedOption)cf2val).getValue()=="No Aplica") || (((LazyLoadedOption)cf2val).getValue()=="Autorizado") && (((LazyLoadedOption)cf3val).getValue()=="Si") )







        results.issues.collect {

            issue -> issueManager.getIssueObject(   

            def issueType = issue.getIssueType().getName()

            def cf4 = customFieldManager.getCustomFieldObjects(issue).find { == "Tipo Test Plan"}

            def cf4val = issue.getCustomFieldValue(cf4) 


                    if ((issue.getIssueType().getName().equals("Test Plan")) && (((LazyLoadedOption)cf4val).getValue()=="Release"))   







                    else if ((issue.getIssueType().getName().equals("Test Plan")==false) || (((LazyLoadedOption)cf4val).getValue()=="Historia Usuario"))




                        invalidInputException = new InvalidInputException("No existe un test plan asociado en el Release o el mismo no esta asignado como Release")

                        invalidInputException = new InvalidInputException(trueCount)






                               if (trueCount >=2)



                                               return true;



                               else if(trueCount2 >=1)



                                                               return false;








        CustomField cf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Celula/Release")

        def cf1val = issue.getCustomFieldValue(cf1)



                if (cf1val!=null)



                               def jqlQuery = "fixVersion in (${issue.getCustomFieldValue(cf1)})"

                               boolean issues = findIssues(jqlQuery)






                               invalidInputException = new InvalidInputException("Debe completar el campo 'Proyecto/Releases' para poder avanzar") 






2 answers

1 accepted

0 votes
Answer accepted

There are a number of things wrong with this script, but I cannot tell you which parts need fixing because I cannot work out what it is supposed to be trying to do.

Could we take a step back and start with a description of what you are trying to achieve?  What do your end-users get out of this?

@Nic Brough _Adaptavist_ ¿

Validation is required when transitioning from the "To do" step to the "Done" step in the workflow, validating that the issues found in the assigned release (s) in the custom field "Cell / Release", these issues must comply with certain conditions to be able to advance the workflow to "done"

The problem I currently have is in the JQL that is running. Since what I can deduce from the error is that the JQL is being entered erroneously

Ok, yes, that is the place I would look.  This line is the problem:

def jqlQuery = "fixVersion in (${issue.getCustomFieldValue(cf1)})"

You are defining a simple string to generate a query here, which is a perfectly valid thing to try to do, as the query builder expects a string of JQL.

But the string you are building there really will come out as

fixVersion in (${issue.getCustomFieldValue(cf1)})

which is not valid JQL.

I think you're looking to build something more like

fixVersion in "Version 42"

To do that, you'll need to build up the string, something like

def jqlQuery = "fixVersion in \"" + $issue.getCustomFieldValue(cf1) + "\""

@Nic Brough _Adaptavist_ 

Works for me! thanks you so much!

0 votes

When someone change a Title of type request is not simultanously change in at JQL Query Queues. Thats Annoying

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,071 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you