Need help with issueFieldMatch() JQL method of script runner

SWAPNIL SRIVASTAV November 17, 2020

I need to perform a case insensitive exact search using issueFieldMatch() method.

To make special characters also readable in the search, I used the following code:

def count = 0    for (def i = 0; i < summary.length(); i++) {        if (summary.charAt(i).toString().matches("[^a-z A-Z0-9]")) {            // Check if there is a single special character found            count++        }    }    if (count > 0) {   //Special character was present in the string        for (def j = 0; j < summary.length();) {            if (summary.charAt(j).toString().matches("[^a-z A-Z0-9]")) {                // To find whether current character is a special character or not                //summary = summary.substring(0, j) + "\\\\" + summary.substring(j)                //Inserting double backslash to make special characters readable in Regex                j = j + 3            } else  //If there was a character which was not a special character                j++        }    }

And, I used the variable in the below query:

def jqlSearch = "issueFunction in issueFieldMatch(\"project='Capacity Forecast' and issuetype ='Cluster Forecast' and 'Forecast' =" + previousForecastVal + "\", 'Summary', '^(?i)${summary}\$') ORDER BY issuekey DESC" 

 

and in the below variable:

def sourcingSummary = "Sourcing: " + forecastIssue.summary + " - " + summarynewsubtask.summary = sourcingSummary 

 

It worked fine for a long time, but now it is giving faulty results. It is returning value of variable "newsubtask.summary" with double backslash included in the string. Seems like we dont need double backslash to escape special characters anymore. Is it so? Has there been any change in the usage of "issueFieldMatch" ?

 

Current Script Runner version: 6.5.0

Current JIRA version: 7.13.5

0 answers

Suggest an answer

Log in or Sign up to answer