JQL query for issues where a custom field is empty or where the custom field isn't associated with the issue

I have a situation where some issues in a project have a custom field, while others do not. If I perform a search like:

project = FOO and customField is EMPTY

This will only return the issues that have the custom field "customField" and where the field is empty, it will exclude all issues that aren't associated with the custom field "customField"

I'm trying to execute a query that will return all issues where either the custom field is empty, or where the custom field is not associated with the issue. Is there a way to do this?

7 answers

1 accepted

This widget could not be displayed.

 

I've found the solution, but it's really hack-ish.

Both customField IS EMPTY and customField IS NOT EMPTY does not return tickets that have no customField at all. So, basically, NOT (customField IS EMPTY OR customField IS NOT EMPTY) should return them. As it turns out, it doesn't. Probably some pre-processing of query etc. But if you save it as a filter, it works. So..

  1. Query for customField IS EMPTY OR customField IS NOT EMPTY
  2. Save filter as Has customField
  3. Open new query window
  4. Now if you search for NOT filter = "Has customField", you get issues that have no customField at all
  5. Your final query should be project = FOO and (customField is EMPTY OR NOT filter = "Has customField")


Script Runer allows implement straigtforward solution with the only JQL query

project = FOO and issueFunction not in expression("project = FOO and (customField IS EMPTY OR customField IS NOT EMPTY)", "created <= today")

It's also slightly hackish, since expression always means "all issues from subquery", but at least it could be done via scripting w/o filter being saved

That worked for me!  Thank you, Andrey!

I've tried doing that just now (I hope I followed the steps correctly). On the last step (the final query) I get this error:

 

Error occurred communicating with the server. Please reload the page and try again.

 

Obviously, no results are returned.

I've also tried a direct query via jira-cli and I also get an error:

 

jira-cli view --search-jql 'project = Development AND NOT (team IS EMPTY OR team IS NOT EMPTY)'

<h1>Page unavailable</h1>
<div class="aui-page-notification-description">
Please check <a href="https://status.atlassian.com">Atlassian Status</a> for any known issues.
<br />
If your page hasn't appeared again in 5-10 minutes, please contact our support team.
</div>
<br>
<p>
<a href="https://status.atlassian.com" class="aui-button aui-button-primary" style="width: 175px;">
Atlassian Status
</a>
&nbsp;
<a href="https://getsupport.atlassian.com/servicedesk/customer/jst" class="aui-button">
Contact support
</a>
</p>

This widget could not be displayed.

In our instalation this sentence it works. Try enclosing field name in quotes:

"CustomField" is EMPTY

Hi All,

I am also facing this issue while I do jql for Component field in a project.

Search1 : project= proj1 and "component" is not EMPTY 

Search2 : project= proj1 and "component" is EMPTY 

Search3 : project= proj1 

For me 

Search3 is not equal to some of Search1 and Search2.

Please advice.,

Regards

Prakhar 

This widget could not be displayed.

I'd like to query for all issues that don't have a value in "Account" (custom field 10101).

"Account is EMPTY" returns all issues (not corrent) "cf[10101] IS EMPTY" also returns everything.

what's the correct way to do this search? JIRA is 6.4m13

This widget could not be displayed.

I second that. The "custom field" is EMPTY does not always work. I think this is a bug in JIRA (mine is 7.0).

I tried to reindex search, but it did not help.

This is somehow related to a situation where you have two or more projects with same set of custom controls. E.g. prj1 contains "custom field" and prj2 also contains "custom field".

 

The correct jql should be the following:

project=prj1 and cf[10201] is EMPTY

, where 10201 is the id of your custom field (you may quess it if you add a search column with your CF value and inspect corresponding html code).



That worked . thanks

This widget could not be displayed.

Use "Re-index project" to solve this issue once and for all

 

2018-05-17 14_35_34-Re-index - ITJIRA.png

This widget could not be displayed.

That is not possible via JQL. You might want to write a plugin or find it from the database if it is a one time task!

Izaskun's answer worked for me.

Not possible without a plugin is the standard answer to every issue.

This widget could not be displayed.

The OP's query actually works now. You don't need quotes.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

232 views 3 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you