Forums

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

Filter for Issues that do not contain specific text in the Comments

Dave Stillwell
Contributor
June 16, 2025

I am trying create a filter that list all issues that do not have specific text (e.g Code 1234) in the comments section.  I have tried comments !~ "Code 1234" with no success but I do get results with comments ~ "Code 1234" (though not the results I am expecting)

We have ScriptRunner installed if that helps.  Could this be a limitation of ScriptRunner?

2 answers

1 accepted

1 vote
Answer accepted
pawarsachin84
Community Champion
June 17, 2025

Hello Dave,

1. If you're doing this regularly, consider: Having users flag issues that include Code 1234 in a label or custom checkbox (e.g., "Code 1234 added").

Then you can use -
project = XXX AND labels != "code-1234"

2. If you have ScriptRunner for Jira, you can try and use its JQL functions

Eg - issueFunction not in issueFieldMatch("project = XXX", "comment", "Code 1234")

his returns issues in project XXX where comments do not contain Code 1234.

Dave Stillwell
Contributor
June 17, 2025

@pawarsachin84 thanks for the feedback.

While it still would be nice to know why my code wasn't working, but the Label idea seems to be an elegant work-around.  I will also try out your recommended JQL function.

Like pawarsachin84 likes this
Dave Stillwell
Contributor
June 17, 2025

@pawarsachin84 

I just tried the AND labels != "code-1234" and it did not work but AND labels = "code-1234" does work.

pawarsachin84
Community Champion
June 18, 2025

@Dave Stillwell - This is expected because: 

labels != "code-1234" does not mean “issues that don’t have this label.”

Instead, it means:

“Issues that have a label, but that label is something other than code-1234.”

So if an issue doesn't have any label at all, it is excluded from the result.

 

To truly get issues that do not have the code-1234 label (including those with no label at all), use this JQL:

project = XXX AND (labels is EMPTY OR labels not in ("code-1234"))

 

Explanation:

  • labels is EMPTY: matches issues with no label at all

  • labels not in ("code-1234"): matches issues with labels, but not this one

Combining both with OR ensures you include:

  • Issues that don’t have any labels

  • Issues that have different labels

Dave Stillwell
Contributor
June 19, 2025

@pawarsachin84 

Thank very much for the clarification.  That makes total sense.

Like pawarsachin84 likes this
0 votes
arielei
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 16, 2025

Hey @Dave Stillwell 

I did a test on my end with the same values your wrote, for me it works.

Screenshot 2025-06-16 at 20.26.00.pngScreenshot 2025-06-16 at 20.26.55.png

Dave Stillwell
Contributor
June 16, 2025

@arielei 

It looks like you are using JSM/Jira for the cloud.  I wonder if it is because I am using Data Center.

I'll create some dummy tickets in my test environment to do some more testing.

Suggest an answer

Log in or Sign up to answer