Wednesday, August 17, 2011

Sort order of select lists in JIRA

I had an "surely I already knew that?" moment the other day. My select list custom field had values A, B and C. I changed the order in the configuration screen to be A, C and B. Yet when I displayed the field in the Issue Navigator list of issues and sorted by it, the issues were sorted alphabetically, not at all how I had configured.

It turns out there's a long-standing bug about this that needs some of your voting love: JRA-14161
Until it's resolved, you have to add a prefix to make the values sort the way you them to, e.g.

01 My First Value
02 Another Value

I can see what the underlying problem is - field contexts. A custom field in JIRA can have contexts associated with it, where a context is project and issuetype. Then you can have different sets of options per context for the same field., e.g.

My Custom Field

Project A, Issue Type T1, options A, B, C
Project A, Issue Type T2, options Z, Y, C

The problem is that there is no sort order defined between these two sets of options. And just because option C occurs in both sets doesn't mean that they would be sorted together since the order is defined per context too. Tricky.

~Matt

No comments:

Post a Comment