Issues using curly braces in JQL
Asked by Greg Bailey:

Hello,

Im attempting to add an automation rule that will have a branch condition JQL to get issues in epics linked to the 'trigger issue'.  

The JQL leverages ScriptRunner JQL functions and it includes the smart value of the trigger issue.  
The problem is that the rule is failing on the JQL saying the curly brace used for the smart value is a reserved character and to put it in a string or use the escaped unicode value of '\\u007b'.

An example of a functioning version of this jql is :
>
> ```
> issueFunction in issuesInEpics(" issueFunction in linkedIssuesOf('key=CCFT-2', 'is implemented by') ") AND status != closed
> ```

Which in a JQL Branch condition would cleanly look like:

```
issueFunction in issuesInEpics(" issueFunction in linkedIssuesOf('key={{issue.key}}', 'is implemented by') ") AND status != closed
```

Below is my current 'version' of the JQL but it is continuing to fail. I've tried numerous 'combination's of escapes to get this pass but have had no luck.

```
 issueFunction in linkedIssuesOf('key=\"{"\"{"issue.key\"}"\"}"', 'is implemented by') ") AND status != closed
```

Another failure failure showing how I had attempted the JQL using the unicode values.
> *CCFT-2: "(issueFunction in issuesInEpics(" issueFunction in linkedIssuesOf('key=\\u007b\\u007bissue.key\\u007d\\u007d', 'is implemented by') ") AND status != closed) AND (key != CCFT-2)" - Error in scripted function: issuesInEpics, see below, Error in scripted function: linkedIssuesOf, see below, Error in the JQL Query: The character '{' is a reserved JQL character. You must enclose it in a string or use the escape '\\u007b' instead. (line 1, character 5)*

How can I correctly format the JQL with escapes to get this JQL to work when triggered in the rule?

Version info:

Jira Server(not Cloud): 8.53

Automation for Jira: 7.2.8

ScriptRunner : 6.2.2

Thanks in advance for any help.

Regards,

Greg


Answers:
author: Greg Bailey
body: Thanks for the response [@Curt Holley](/t5/user/viewprofilepage/user-id/3527535)  

You are correct for a single link i.e. a story linked in an epic your solution would work.  
However, in my case Im looking for issues in epic with that epic linked to another epic.  

the problem was with the jql string I was creating was having issues getting the correct escapes in place to manage the quotes and brackets. So when I ran the query it failed.  

I was able to solve this by using the string quoting of '/'.  

I ended up with this and it is now working just fine:  

```
// trigger issue and jql strings
def jqlPrefix=/issueFunction in issuesInEpics("issueFunction in linkedIssuesOf('key=/
def jqlSuffix=issueKey + /', 'is implemented by') ") AND status != closed/

// The JQL query you want to search with
final jqlSearch =jqlPrefix + jqlSuffix
```

<br />

I only got back to this task yesterday and came up with this solution and neglected to post here.   

I'll mark this as done/answered.  

Thanks again,

Greg

comments: author: Curt Holley
body: Right. I missed the epic linked to another epic part.

Complicated situation, well handled ?


author: Curt Holley
body: HI

I'm only familiar with the Cloud version of Automation, but ignoring my trigger/insert whatever trigger is relevant....wouldn't something like this work? plus no scriptrunner functions required.

![idea.png](https://community.atlassian.com/t5/image/serverpage/image-id/138539iA808E1B8746F69B8/image-size/large?v=v2&px=999 "idea.png")


Tags: jql

smart-value