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")}}
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.