Alphabetically order custom connect app single/multiple select values

HI
We have several connect app descriptor issue fields (https://developer.atlassian.com/cloud/jira/platform/modules/issue-field/) that are single or multiple select fields.
We populate them with the API with additional values over time, eg added a,b,c,d,e initially then over time added bb,cc,aa,bbb,dd and then again added items like ee,aaa. - this then results in a dropdown showing a,b,c,d,e,bb,cc,aa,bbb,dd,ee,aaa and not a,aa,aaa,b,bb,bbb,c,cc,d,dd,e,ee.
How can we auto-alphabeticize the dropdown for the single/multi select fields with each update via the API or other automated fashion?
Thank in advance
Yatish

Hello @YatishMadhav

This question has been asked quite a few times. The REST API endpoints for managing the contents of issue fields do not have any ‘auto sorting’ capability. New values are just appended to the end of the set of existing values.

The only way to achieve the outcome you describe is to totally erase the set of values and re-build it in the sequence you need.

  1. Get all the values of the select field and store them in an array in your code
  2. Add the new value(s) to the array, then sort the array alphabetically
  3. Erase the set of values of the select field
  4. Upload the new set of values in the order stored in the sorted array

Thanks for the reply here as well @sunnyape

Yeah, I have see it in a few places and have seen this https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-field-fieldid-context-contextid-option-move-put but not exactly what we want to do.

Yeah, that was a thought we did have initially BUT this would assign new ids to each of the options which may break other automation :frowning: A catch 22.

First prize would be to have the ability to sort the field options by ID or by value … Do you know of a ticket I can upvote or watch for this? Or should I also raise a support/feature request for it?

Thank you
Yatish

The endpoints for moving items in a custom list are fairly new and I’ve not had a reason to use them yet, but I suppose it’s reasonable to assume you can use it to move a new value to a particular place to make it in be in the correct alphabetic order. This at least would preserve the existing values and their IDs.

You’d still need to lookup all the current values in the list first, then do an offline add of your new value, then sort the set alphabetically to know what location the new value would need to be moved to after you added it… but boy, that’s a real overhead of work and processing just to keep all the IDs of the existing values intact just because some other automation has that requirement.

Doing some things via the REST API are just cumbersome, and there’s no shortcut.

Search through the existing Jira Cloud feature requests to see if anyone else has suggested such a ‘self sorting’ capability when new values are added to a list field, but your chances are slim.

Good luck.

:frowning: oh! I actually meant to post this link https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options--apps-/#api-group-issue-custom-field-options--apps-

Does not look like we can order options in fields created be apps! :frowning:

To your suggestion for the workflow, yes, very exhaustive. Would be nice to just be able to have it sorted when needed or as default :slight_smile:

Thanks again @sunnyape