Hi Community, I need help.
I use this code in behaviours, to filter the options that start with "Team - " into a multi-select custom field that has dozens of values.
It actually works, but I recently discovered that it displays all values starting with "Team - " even the disabled ones.
Is there any way to not display the disabled but continue with the name filter?
import com.atlassian.jira.component.ComponentAccessor
def singleSelect = getFieldById(getFieldChanged())
def optionsManager = ComponentAccessor.getOptionsManager()
def cf = getFieldByName("Team")
def cfField = customFieldManager.getCustomFieldObject(cf.getFieldId())
def cfConfig = cfField.getRelevantConfig(getIssueContext())
def cfOptions = optionsManager.getOptions(cfConfig)
def cfA = cfOptions.findAll { it.value.toString() contains 'Team - '
}.collectEntries { [ (it.optionId.toString()) : it.value ] }
cf.setFieldOptions(cfA)
Sure, just filter using the "getDisabled()" method of the Option Class
def cfA = cfOptions.findAll{ it.value.startsWith('Team -') && !it.disabled}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.