The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Sort custom field options using a script?

Payne
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 Champions.
February 2, 2024

Does anyone know of a way to programmatically sort the options in a Select List custom field? It can be accomplished via the UI using the link indicated in this screenshot, but we programmatically add items to a couple of lists and would like to also be able to programmatically sort the lists after doing do. We use the OptionsManager interface, which offers several methods for managing lists, but none for sorting. Thanks!

jirascreenshot.JPG

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Rolf Lader
Community Champion
April 28, 2025

@PD Sheehan,

I have tried to follow your recommendation and have done this as follows

options.sortOptionsByValue( null )
optionsManager.updateOptions( options )

Unfortunately not with the desired success. Can you tell me what I am doing wrong?

0 votes
Payne
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 Champions.
February 23, 2024

Thanks, Peter-Dave. Even better, I found a sortOptionsByValue() method in the Options class and am accomplishing the task as follows:

ComponentAccessor.getOptionsManager().getOptions(fieldConfig).sortOptionsByValue(null)

0 votes
PD Sheehan
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 Champions.
February 3, 2024

With the OptionsManager interface, you can retrieve the list of options, sort it in memory and adjust the sequence field for each option, then use "updateOptions()" to save the new sorted list.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events