Forums

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

JQL - Writing AND statements that require another nested AND?

Tyson Neil Taber May 8, 2018

I have a custom filter written in JQL with several consecutive AND statements combined with != due to the required field to search does not support list use like (A,B,C).

I need to add another AND condition but that condition must also contain another AND operator. Something like:

... AND (component != R AND type != S) AND...

The above is for reference to what I'm trying and is not valid JQL.

Is this possible?

1 answer

1 accepted

3 votes
Answer accepted
Josh Steckler
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.
May 8, 2018

Can you post the whole JQL? Nested segments and all. Feel free to obscure field names/values.

Also is there more to the error for invalid JQL?

Tyson Neil Taber May 8, 2018

status = Open AND component in ("A", "B", "C", "D", "E", "F", "G", "H", "I") AND cf[11802] != CUSTOMER1 AND cf[11802] != " CUSTOMER2" AND cf[11802] != " CUSTOMER3" AND cf[11802] != " CUSTOMER4" AND cf[11802] != " CUSTOMER5" AND cf[11802] != " CUSTOMER6" AND cf[11802] != " CUSTOMER7" AND cf[11802] != " CUSTOMER8" AND cf[11802] != " CUSTOMER9" AND cf[11802] != " CUSTOMER10" AND cf[11802] != " CUSTOMER11" AND cf[11802] != " CUSTOMER12" AND cf[11802] != " CUSTOMER13" ORDER BY created DESC, key DESC

 

I need to add an “AND not equal” for something that will look at cf[11802] AND another custom filed for TYPE of certain criteria and not display those.

The error you recieve when trying to do "cf[11802] != (A,B,C,D,etc.) is that the field does not support list values.

Josh Steckler
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.
May 8, 2018

What type of custom field is it for this part:
cf[11802] != (A,B,C,D,etc.)

You might be need the Not In () operator if you're using a select field or similar and want to exclude several options. 

Tyson Neil Taber May 8, 2018

it is a Select List (Single Choice) Field of Global Type

as note, the second custom field I'm looking to combine with "Customer14" is also a Select List (Single Choice) Field of Global Type

was that the right answer?

Also, I only want to address the second field (which does appear on all other tickets) for Customer 14.  If I try to add another operator for the second custom field, it eliminates ones for customers I want to see.

Josh Steckler
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.
May 8, 2018

So could you accomplish this using:

(cf[11802] not in ("Customer1", "Customer2", "Customer3", ....) and status = Open AND component in ("A", "B", "C", "D", "E", "F", "G", "H", "I")) OR (cf[11902] = "Customer14" and cf[99999] = "abcdef")  order by created desc, key desc
Tyson Neil Taber May 8, 2018

It was pretty close, I added an AND status = OPEN statement to the CUSTOMER14 section after the OR statement, and that reduced the display a bit as well.

Also, I made sure to include the CUSTOMER14 name in the first statement for "not equals", then also used CUSTOMER14 after the OR statement to say to include that customer name with the AND for priority, and it worked!

THANK YOU SO MUCH!!!!!

Josh Steckler
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.
May 8, 2018

Happy to help 😀

Tyson Neil Taber May 8, 2018

Here is the final JQL:

cf[11802] not in (CUSTOMER1, CUSTOMER2, CUSTOMER3, CUSTOMER4, CUSTOMER5, CUSTOMER6, CUSTOMER7, CUSTOMER8, CUSTOMER9, CUSTOMER10, CUSTOMER11, CUSTOMER12, CUSTOMER13, CUSTOMER14) AND status = Open AND component in(A, B, C, D, E, F, G, H, I) OR cf[11802] = CUSTOMER 14 AND priority = “P1” AND status = Open ORDER BY created DESC, key DESC

"hi5"

Suggest an answer

Log in or Sign up to answer