I am using a JQL query in my code that I am writing in the script console of Jira and I am having some issues with the quotes in the script console as you can see below.
Here is the code:
def query3 = ""
try{
query3 = jqlQueryParser.parseQuery("project = \""+myproject.getName()+"\" and created >= -365d and issuetype in (""\"Defect"\"", "Code Roll-in - Maintenance", "Code Roll-in - New Version"))
}catch(Exception e){
log.warn("MounaException "+e)
}
Anyone knows how to fix this problem?
Hey @Mouna Hammoudi ,
Figuring out where and what to escape is always a hassle.
In my experience the easy fix was to mix single and double quotes where you use one for the String definition and the other for the query isolation
I have combined single and double quotes and it is not working either as you can see below. Could you please write to me your suggestion? Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't have an instance to test on right now but I'd suggest giving this one a try:
query3 = jqlQueryParser.parseQuery('project = \"'+myproject.getName()+ \"' and created >= -365d and issuetype in (\"Defect\",\"Code Roll-in - Maintenance\",\"Code Roll-in - New Version\")')
You basically use single quotes to open/close the string and double quotes to put around the parameters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have tried it but it's not working, do you have another suggestion? I am completely lost and you have more experience than me. Here is what I got once I copied and pasted your code:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems I misplaced a quote. Give this one try please.
query3 = jqlQueryParser.parseQuery('project = \"'+myproject.getName()+ '\" and created >= -365d and issuetype in (\"Defect\",\"Code Roll-in - Maintenance\",\"Code Roll-in - New Version\")')
Otherwise could you also tell us what error message you have?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It works now. thank you so much!
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.