Forums

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

Query on scripted (ScripRunner) / custom fields doe snot work as expected

Klaus Foerschl
Contributor
July 17, 2018

We have (ScriptRunner) a scripted custom field Affected Sub Domains, gathering Information from all linked issues of an issue type "Software-Tool"

The scripted field uses the "Free Text (mult line)" template and is configured to use the "Free Text Searcher".

Dependent on if there are one or more linked issues, the calculated text field contains a string, representing a (comma separated) list of values.

Concrete examples (yes, the value is really just one character)

"Affected Sub Domains" = "A" (there's only one linked issue, which has a custom field "Sub Domain" with value "A")

"Affected Sub Domains" = "A, C" (there are at least two linked issues, where one has a custom field "Sub Domain" with value "A" and another linked issue where "Sub Domain" = "C")

A simple search like:

project = ITT AND issuetype = Software-Tool" (displaying the "Affected Sub Domains" field)

returns all expected issues and Shows values like "A", "C" and "A, C" in the "Affected Sub Domains" column.

Now trying to restrict the results to only a sub set, where Affected Sub Domains contains "C", it seems to work with this query:

project = ITT AND issuetype = Software-Tool and "Affected Sub Domains" ~ C

It results in a list of matches, where Affected Sub Domains is either "C" or "A, C". All issues, where Affected Sub Domains would only be "A" are not returned.

So, this is how we expect it to be.

But, now performing a search, which should only return issues which belong to Sub Domain "A", the following query does not return any results (NOTE: it's exactly the same JQL as abobe with only the value Changed from C to A)

project = ITT AND issuetype = Software-Tool and "Affected Sub Domains" ~ A 

Any Explanation and Suggestion how to make it work?

We already tried to work with other searchers like the "Exact text searcher" and both searchers from the "Natural Searchers for JIRA" plugin.

No success so far.

Any hint is very welcome.

1 answer

1 accepted

0 votes
Answer accepted
Tarun Sapra
Community Champion
July 17, 2018

Hello @Klaus Foerschl

I personally find using the native tild operator a bit unpredictable at times, thus If I have to write JQL like in your case to match string or part of it then I try using the Script Runner's JQL functions

issueFieldExactMatch

issueFieldMatch

Can you modify your JQL to try any one of the above functions instead. 

https://scriptrunner.adaptavist.com/latest/jira/jql-functions.html

Klaus Foerschl
Contributor
July 18, 2018

Hi Tarun. Thanks a lot for this hint. It works perfectly well. I was not yet Aware about all those JQL script functions. So, i learned for the future.

Tarun Sapra
Community Champion
July 18, 2018

Glad to know that it helped!

Suggest an answer

Log in or Sign up to answer