I created three custom fields based on one field i want to set options for remaining two , but i want remaining two fields as read-only and these three are mutli-select fields
script i am using in behaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def customFieldManager = ComponentAccessor.customFieldManager
FormField oneField = getFieldByName("Function Group (all)")
FormField twoField = getFieldByName("Domain Group")
FormField threeField = getFieldByName("Only Domain")
twoField.setReadOnly(false)
threeField.setReadOnly(false)
def selectedValues = oneField.getValue() as List
twoField.setFormValue([])
threeField.setFormValue([])
def twoCustomField = customFieldManager.getCustomFieldObject(twoField.getFieldId())
def threeCustomField = customFieldManager.getCustomFieldObject(threeField.getFieldId())
def issueContext = getIssueContext()
def twoConfig = twoCustomField.getRelevantConfig(issueContext)
def twoOptions = optionsManager.getOptions(twoConfig)
def threeConfig = threeCustomField.getRelevantConfig(issueContext)
def threeOptions = optionsManager.getOptions(threeConfig)
def optionsToSetForTwo = []
def optionsToSetForThree = []
twoOptions.each { println "Two Option: ${it.value}, ID: ${it.optionId}" }
threeOptions.each { println "Three Option: ${it.value}, ID: ${it.optionId}" }
selectedValues.each { value ->
def parts = value.toString().split('-')
if (parts.size() >= 2) {
def twoValue = parts[0]
def threeValue = parts[1]
// Accumulate options for "Two"
twoOptions.findAll { it.getValue() == twoValue }.each { twoOption ->
optionsToSetForTwo << twoOption.getOptionId().toString()
}
// Accumulate options for "Three"
threeOptions.findAll { it.getValue() == threeValue }.each { threeOption ->
optionsToSetForThree << threeOption.getOptionId().toString()
}
}
}
twoField.setFormValue(optionsToSetForTwo.unique())
threeField.setFormValue(optionsToSetForThree.unique())
twoField.setReadOnly(true)
threeField.setReadOnly(true)