Sort by ID rather than Name of a custom field in JQL(JIRA)

Raju KC
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.
November 19, 2013

I have a custom-field "MONTH" with options: jan, feb,..,dec.

Now I want to sort by MONTH so that order will be jan,feb..... Is it possible?

3 answers

1 accepted

0 votes
Answer accepted
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.
November 19, 2013

Jira isn't clever enough to recognise abstracted names like that. I used to cheat by simply padding the names with empty space prefixes, but that's a bit horrid when you do it in JQL. For months, the only fixes I know of are:

  • Prefix month names with 01, 02, 03 etc
  • Write a field that understands that the options are months
  • Wedge in some javascript to do the sort (I avoid javascript as much as possible, and I'm not sure it'll help you here - I suspect you're looking at JQL, where javascript won't help you at all)
0 votes
Norman Abramovitz
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.
November 19, 2013

I am not sure if this answer is covered by Nic's second case, but I have populated a second field with the sort order then using jql to sort by that column. The column does not need to be displayed to sort by it.

Raju KC
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.
November 19, 2013

Norman,

I am not getting - Can you please elaborate in more details?

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.
November 19, 2013

It's fourth valid way to do it - you create a new field called something like "sorted month", then use a plugin (script runner) to create a calculated field that populates it with 1 if your main field is Jan, 2 for Feb and so on.

Then your JQL could be something like "month in (Jan, Mar, Apr) order by sorted-month

(My third option was to write a field type plugin that gives you that works like any other select list, but has code that knows how to sort month names correctly. That is more coding than Norman's idea, but the JQL works more intuitively)

Norman Abramovitz
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.
November 21, 2013

Thank you Nic for clarifying my terse description. Your description is exactly what I did and it took no more than 15 minutes to implement.

0 votes
Udo Brand
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.
November 19, 2013

I doubt it, since it will sort the content of that field alphabetically.

Suggest an answer

Log in or Sign up to answer