Forums

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

JMWE SearchIssues with special characters in summary

Ahmad Sidawi
Contributor
August 25, 2023

Hi,

 

We have many tickets which contain characters like '-', '_', '|'. In JQL we can apply something like this to run a query without issue:

https://confluence.atlassian.com/jirasoftwareserver/search-syntax-for-text-fields-939938747.html

 

I'm trying to run something similar in JMWE but unable to get the right syntax, any help would be appreciated :) 

 

What i've tried (which works fine for items without special characters in the summary):

{{('project = XYZ and issuetype = "XYZ" and summary ~ ' + '"/"' + issue.fields.summary + '/""' + ' order by created DESC') | searchIssues(maxResults = 1, fields = "key") | field("key")}}

1 answer

0 votes
Steve Diaz August 26, 2023

Hello

It seems like you're trying to construct a Jira Query Language (JQL) query using JMWE (Jira Misc Workflow Extensions) that includes special characters like '-', '_', and '|'. These characters can affect the syntax and behavior of your query. Here's how you might adjust your query to handle special characters properly:

def summary = issue.fields.summary.replaceAll('[-_|]', '\\\\$0') def jqlQuery = 'project = XYZ and issuetype = "XYZ" and summary ~ "' + summary + '" order by created DESC' def result = (jqlQuery) | searchIssues(maxResults = 1, fields = "key") | field("key") return result

In this modified code, I've used the replaceAll method to escape the special characters '-' (hyphen), '_' (underscore), and '|' (pipe) with double backslashes. This ensures that these characters are correctly interpreted within the JQL query string.

 

Thank you.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events