Find issues with specific SLA field beeing empty

Corentin Méhat
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.
January 10, 2017

Hello,

Is there a way to create a JQL matching issues where a certain SLA field is empty ?

The only operators I found where numeric ones (=, <, >, ...) but I couldn't find any "is empty" operator for example.

It's JSD 1.2.6.1 / JIRA 6.3.15 , but I wonder if this is possible with latest versions.

 

Thanks in advance for your help,

3 answers

1 accepted

11 votes
Answer accepted
Morgan Knicely
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 13, 2018

My co-worker asked this question and I thought it was simple. I was so wrong! I couldn't let it go and spent some time investigating this question of "find not breached".

Base set

project = MYPROJECT

100 issues

SLA is breached

project = MYPROJECT AND "My SLA" = breached()

5 issues

SLA is not breached

project = MYPROJECT AND "My SLA" != breached()

50 issues

Hrm, I would think that issues where the SLA has not been run would be included in the results. That's now how Jira typically works though. Usually in JQL, "!=" does not include issues where what you're searching for is EMPTY e.g. null. This search only returns issues that have the SLA field populated and the SLA is breached. It leaves out the ones that have no value for this SLA at all.

Attempts to find SLA is empty / unset / null

You might think we could invert the "= breached()" part to find the empties, but nope, that yields that same answer as above.

project = MYPROJECT AND NOT ("My SLA" = breached())

50 issues

So just to drive this home, using these SLA functions will only show us issues that have run that SLA, breach or not. Here is how to get all issues that have run this SLA.

project = MYPROJECT AND ("My SLA" = breached() OR "My SLA" != breached())

55 issues

We can't invert this either... JQL parses the query, flattens it out, and comes up with 0 issues just like it did before. For JQL, there aren't any issues that have run this SLA which are not either breached or not breached. My head hurts!

project = MYPROJECT AND NOT ("My SLA" = breached() OR "My SLA" != breached())

0 issues

The Solution

We'll take advantage of another JQL quirk to solve this. When Jira evaluates saved filters it doesn't fetch it and flatten out the query like it does above. It just gets all issues from the saved filter and compares it to the rest of the query result. So if we save "Time to response" = breached() in a filter, we can use it to get everything else that doesn't match.

Save a filter named "My SLA Not Empty" with this JQL:
project = MYPROJECT AND "My SLA" = breached() OR "My SLA" != breached()

55 issues

Now we can reference this filter and invert it to exclude issues that DO have the SLA.

project = MYPROJECT AND filter != "My SLA Not Empty"

45 issues

We have a winner!

There's a Feature Suggestion for this to make it easier. Vote it up! https://jira.atlassian.com/browse/JSDSERVER-4650

One thing to watch out for is that in really large instances referencing filters in this way (sub queries) can create excessive memory pressure. Jira retrieves all issues that match the referenced filter, retrieves the issues from the rest of the JQL, and processes them in memory to return the desired result set. Check how many issues are returned by your saved "SLA Not Empty" filter. If it is many thousands, consider narrowing it down with created > DATE or other criteria to reduce the number of issues to compare.

Corentin Méhat
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.
April 13, 2018

Accepting your solution since it seems to work, but I'd rather have the JSDSERVER-4650 for a clean way to solve this :-)

Jean-Michel Bernard January 26, 2022

Amazingly overcomplicated workaround for a feature that would seem very obvious to have.

I added my 2 cents in a comment in the suggestion ticket.

Ansar Rezaei
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.
April 18, 2023

I tried the solution you suggested, but it shows this error:

Field 'filter' with value 'My Saved Filter' matches filter 'My Saved Filter' and causes a cyclical reference, this query can not be executed and should be edited.
Could you provide more advice here?
Ansar Rezaei
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.
April 18, 2023

It's solved by adding the () In the query:

project = MYPROJECT AND ("My SLA" = breached() OR "My SLA" != breached())

0 votes
Ismael Olusula Jimoh January 13, 2017

This operation was intentionally not added as from our knowledge of it, the SLA should be based on what was configured by the project Admin, hence all issues that fit the JQL which uses the SLA would be affected.

Instead of looking for the SLA in such a case, search for the JQL for the SLA as all issues that fit it should be empty as well.

If there is a special use case where the SLA value is somehow cleared, we would recommend fixing the SLA itself.

There is a suggestion raised here: https://jira.atlassian.com/browse/JSD-4650 for this feature and probably more light would be shared on this by the developers on the ticket for anyone interested.

Corentin Méhat
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.
January 13, 2017

Hello,

Thanks for sharing the link, I was going to do it just now after creating the suggestion smile

0 votes
Vladimir Yakimov _Botron_
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.
January 11, 2017

Hi, 

Just tried in 3.2.7 and 3.3.0 and it's not possible in later releases either. Same operator options available.

Regards,

Vladimir

Suggest an answer

Log in or Sign up to answer