Skip to content

Instantly share code, notes, and snippets.

@jechlin
Created September 13, 2016 19:48
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jechlin/f951aff26dd83197cba1e88b66683a6d to your computer and use it in GitHub Desktop.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("CascadingSelect") // <- change name of field
Closure formatOption
def sb = new StringBuilder()
formatOption = { int depth, Option option ->
sb << (("\t" * depth) + option.value + "\n")
depth++
option.childOptions.each {
formatOption(depth, it)
}
}
cf.getConfigurationSchemes().each { fieldConfigScheme ->
def fieldConfig = fieldConfigScheme.getOneAndOnlyConfig()
sb << "Options for ${fieldConfigScheme.name}\n\n"
optionsManager.getOptions(fieldConfig).each {
formatOption(0, it)
}
}
"<pre>" + sb.toString() + "</pre>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment