Custom field options having null sequence


We fall into this issue

But I am not able to access workaround script from here

Can anyone please post me here as an answer ??



2 answers

optionsByFieldConfig.each {fieldConfig, fcOptionList ->
            fcOptionList.groupBy {it.parentOption}.each {parentOption, optionList ->
                if (optionList.any {it.sequence == null}) {
                    log.debug("Modify options for field config ${}")
                    // find highest sequence number to use as the base
                    def highestSeq = optionList*.sequence.max() ?: -1
                    optionList.findAll {it.sequence == null}.sort{it.optionId}.eachWithIndex {Option option, Integer kount ->
                        log.debug("Update option with ID ${option.optionId} and value ${option.value}")
                        if (! isPreview) {
                            option.setSequence(highestSeq + kount)
        log.debug("Updated or will update: ${totalOptionsToUpdate} options in total")
new FixBrokenOptionsScript().run()

package examples
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.fields.layout.field.AbstractFieldLayoutManager
import com.atlassian.jira.issue.managers.DefaultCustomFieldManager
import org.apache.log4j.Level
import org.apache.log4j.Logger
public class FixBrokenOptionsScript {
    def log = Logger.getLogger("examples.FixBrokenOptionsScript")
    // set isPreview to true to see what would be done - check the logs
    def isPreview = false
    public void run() {
        def totalOptionsToUpdate = 0
        def optionsManager = ComponentAccessor.getOptionsManager()
        def Map<FieldConfig, List<Option>> optionsByFieldConfig = optionsManager.getAllOptions().groupBy {
            try {
            catch (e) {
                // some options can be broken, they refer to a deleted field config or something
                return null

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,898 views 12 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot