Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can I use the JQL IN operator without sorting, to preserve the "originally listed" order?

Midori
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.
October 9, 2015

I'd like to be sure that a JQL query like this preserves the order in its output:

key in (WEB-110,WEB-111,CARCH-20,WEB-112,JPDF-5,WEB-113)

So the expected output would be the issues in this order: 

WEB-110,WEB-111,CARCH-20,WEB-112,JPDF-5,WEB-113

Instead, we receive them in this order:

WEB-113,WEB-112,WEB-111,WEB-110,JPDF-5,CARCH-20

(So it looks that JIRA returns them in some default "project desc, key desc" order?!)

Is this possible to tell JIRA not to resort the result?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Ignacio Pulgar
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.
October 9, 2015

The only way I know to change the order of the retrieved results would be through the ORDER BY keyword.

If the order you wish to get doesn't match any other more appropriate field (ie: created, updated, resolved...), then you can follow this quick approach:

  1. Edit each issue to assign the order number -in which that specific issue should be shown- to the field "labels".
    In WEB-110, add a new label named named '100', add '200' to WEB-111, and so on up to WEB-113 '600'.
    These numbers are treated as strings of text, so mind that the order is alphabetical.
    We are using 3 digit names for the labels so that you can add another issue in between them afterwards without modifying any labels. 
  2. Execute the JQL:

    key IN (WEB-110,WEB-111,CARCH-20,WEB-112,JPDF-5,WEB-113) ORDER BY labels


Note that this workaround will fail if those issues have any other labels besides the one containing its order number.

There's a more elegant approach, involving the creation of a numeric custom field.

Midori
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.
October 11, 2015

Thank, Volodymyr. Unfortunately, in this scenario I don't have the rights the control to add custom fields, so I can't use this workaround.

Midori
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.
October 11, 2015

Sorry, I copied over the answer from the other answer. I meant "Thanks, Ignacio", of course.

Ignacio Pulgar
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.
October 13, 2015

Have you tried the labels approach?

Midori
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.
October 13, 2015

Unfortunately, I cannot modify the issues at all, so this wasn't a solution. (It seems that we may even re-sort the result set in our own code...)

Ignacio Pulgar
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.
October 13, 2015

If you interact with JIRA programmatically, then you should sort the result set within your code, which is even a better approach than both of my 'workarounds' using just JIRA.

Midori
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.
October 13, 2015

Yep, that's we have concluded, too. Thanks!

0 votes
Volodymyr Krupach
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.
October 9, 2015

Why do not you sort them by adding "order by". If order based on standard fields does not suit you can add custom number field "Order" and set values for it 1,2,3,4...

Midori
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.
October 11, 2015

Thank, Volodymyr. Unfortunately, in this scenario I don't have the rights the control to add custom fields, so I can't use this workaround.

TAGS
AUG Leaders

Atlassian Community Events