Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax for nested issuefunction

Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 10, 2023

Hey All,

@Radek Dostál  in the below link shared a way to use quotations 4 levels deep.. If I follow his hierarchy it works and if I change the order it does not... so seems like this is some rule...but in my case, in one of the inner clauses, I need to search for free text and that needs its own quotations.. so wondering if there is any clear documentation for this..

https://community.atlassian.com/t5/Jira-questions/Proper-syntax-for-doing-quadruple-nested-issueFunction-JQL/qaq-p/1647631

  • 4th level (outer): '
  • 3rd level: \'
  • 2nd level: "
  • 1st level (inner): \\\'

 

1 answer

1 accepted

1 vote
Answer accepted
Pablo Brincat
Contributor
November 17, 2023

Hello Bizz,

 

Nested issueFunction queries in JQL (Jira Query Language) can indeed become complex, especially when dealing with multiple levels of quotation marks. The key to managing this complexity is understanding how Jira processes these quotation marks at different nesting levels.

 

The hierarchy shared by Radek Dostál in the Atlassian Community post you referenced suggests a pattern for escaping quotations at each level to ensure that the query is parsed correctly. Here’s a quick breakdown:

 

  • 4th Level (Outermost): Single quotes '
  • 3rd Level: Escaped single quote \'
  • 2nd Level: Double quotes "
  • 1st Level (Innermost): Triple escaped single quote \\\'

When you need to include a free-text search within one of these nested clauses, it can get tricky, especially if the text itself contains quotation marks. The goal is to ensure that each level of nesting correctly escapes the quotations of its inner level.

 

Example Scenario

 

Suppose you have a nested issueFunction query where, at the second level, you need to search for a phrase like "Free Text".

 

  • Outer Query: '
  • Inner Query: \"Free Text\"

Constructing the Query

 

You would construct the query by embedding the inner query into the outer one, ensuring that you escape the quotation marks correctly at each level. Here’s a hypothetical example:

 

issueFunction in someFunction('...other criteria... AND issueFunction in anotherFunction(\"Free Text\")')

Tips for Complex Queries

 

  1. Start from the Innermost Part: Build your query from the inside out. Get the innermost query working first, then embed it into the next level.

  2. Testing Incrementally: Test each level of nesting separately to ensure that it returns the expected results before combining them.

  3. Escaping Characters: Pay special attention to escaping characters. In JQL, the backslash (\) is used to escape quotes.

  4. Consult Jira Documentation: For complex queries, refer to the Jira documentation or Atlassian Community for examples and guidelines.

  5. Use a Text Editor: A text editor that highlights syntax can be helpful in visualizing the structure of your query and ensuring correct quotation usage.

  6. Avoid Overcomplication: If a query becomes too complex, consider if it can be simplified or broken down into multiple simpler queries.

Additional Resources

 

For specific syntax related to issueFunction and ScriptRunner (if you’re using it), consult the relevant documentation or community forums. ScriptRunner’s documentation often provides examples of complex JQL functions, which can be very helpful in understanding the syntax.

 

Remember, the key is ensuring that each level of nesting correctly interprets its inner query, which is achieved by proper use of escape characters for quotations.

Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 17, 2023

Awesome, thank you @Pablo Brincat for the detailed answer. Yes, I usually break inner ones into its own filter but was curious if I had to do it, how to properly escape and this info by you helps a lot with planning for future!

Suggest an answer

Log in or Sign up to answer