IF statement in JQL Filter

Jaime Brian June 7, 2017

Hi

I have a custom field in my Epic type where I need to display information based on a variable within 'Component'.  Is there a way this can be written for a JQL filter?

Example of this is:

If (Project = Optimus and Component = HR AND status != "3. Completed" ORDER BY status ASC), (Project = Optimus and Component = CXP AND status != "3. Completed" ORDER BY status ASC)

Is this possible?

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 7, 2017

No.  JQL is not SQL, it's a simple search for a list of issues that match the criteria in it.

You can achieve this by providing calculated data to search on if you put a bit of effort into it.  You've got two searches in your query, and it's not clear what the "if" is supposed to be doing (where's the "then/else" part?), so I can't quite work out what you're looking for.


As an aside, there's no chance of your "order by" working - a result set can only have one order

Jaime Brian June 7, 2017

Thank you.  Sorry to confuse.  

If Component = HR display issues where the status is not equal to completed and order by ASC

ELSE

Component = CXP display issues where the status is not equal to completed and order by ASC

 

I hope this helps to clarify what I want to do.  The reason this has come up is I have installed the add-on Issue Matrix where it adds a visualisation based on a JQL Filter or Custom JQL mode

 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 7, 2017

Ah, ok, well, you can get close to that without coding.

I am assuming the "else" is subordinate in this, and it needs spelling out because any issue could fall into one of four classes:

  • Neither component is on it
  • HR is on it
  • CXP is on it
  • HR and CXP are both on it

I think you want to try:

Project = Optimus and status != Completed and (Component = HR or (Component != HR and Component = CXP) )

Your "order by" is still not making sense though - you're not ordering by anything at all, and even if you were, it's one search, with one order, not two.

Jaime Brian June 7, 2017

OK i see you point about ordering (obvious I am new to this)

If

Component = HR only display issues where the status is not equal to completed and order by status

ELSE IF 

Component = CXP only display issues where the status is not equal to completed and order by "CXP type"

The intended result will be that when I open the EPIC with component = HR it will only display tasks created with the component = HR and then order it by the status field

where as if I open the EPIC with component = CXP it will only display tasks created with the component = CXP and then order it by the "CXP Type" field

The addon issue matrix displays configured columns (picture attached to demonstrate this). you can see by this at the moment that it displays all tasks with the status of Planning.  Not just the ones for component HR.  Yes there are more than just HR and CXP.  I figured once I get the basics down I can add the extra as necessary

Screen Shot 2017-06-08 at 10.17.58 am.png

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 7, 2017

This is not going to work - you've built up an over-complicated requirement that can't be done without a lot of extra work.

A JQL query returns a list of issues that match a set of search criteria.  The criteria are applied to each issue independently of the others.  It gives you a simple list of issues that match.

There is no "if". 

There is a single sort order for the results.

The only way you're going to get your "if" in is with some code that calculates data that enables you to select on compounded parameters.  I think you can also make that do the sort order, but it's going to be even more complex.

Suggest an answer

Log in or Sign up to answer