filter/display options (only active ones) in multi-select

Dante Labate January 5, 2023

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)

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2023

Sure, just filter using the "getDisabled()" method of the Option Class

def cfA = cfOptions.findAll{ it.value.startsWith('Team -') && !it.disabled}
Dante Labate January 6, 2023

Hi @Peter-Dave Sheehan 

 

Thanks again!

worked perfectly!

TAGS
AUG Leaders

Atlassian Community Events