Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need help with issueFieldMatch() JQL method of script runner

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
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

866 views 14 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you