Page tree
Skip to end of metadata
Go to start of metadata
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

final String fieldName = "Cascading Select"
final String parentValue = "AAA"
final String childValue = "A1"

def field = getFieldByName(fieldName)
def optionsManager = ComponentAccessor.optionsManager
def customField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issueContext.projectId, issueContext.issueTypeId).findByName(fieldName)

assert customField : "Could not find custom field with name $fieldName"

def fieldConfig = customField.getRelevantConfig(issueContext)
def options = optionsManager.getOptions(fieldConfig)


def parentOption = options.find { it.value == parentValue }
def childOption = parentOption?.childOptions?.find { it.value == childValue }

assert parentOption && childOption : "One ore more of the given option values are not available"

field.setFormValue([parentOption.optionId, childOption.optionId])

  • No labels