We use Jira Data Center with ScriptRunner, and have a need to remove the “None” option from one of our custom select list fields.
I have already looked at a few discussion threads, and based on them, here are the steps I took:
- Added a new value (in Jira field configuration) called Undefined and set it as the default to use instead of None
- Created a new behaviour, and:
- Added the following code to the initializer
- Added the same code below to the server side script
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Level
import org.apache.log4j.Logger
// Grab appropriate managers
def cfManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
// Grab form and custom field values
def selectCF = cfManager.getCustomFieldObject("customfield_11616")
def selectField = getFieldById ("customfield_11616")
// Must grab the relevant config given the current issue context and the custom field
def config = selectCF.getRelevantConfig(getIssueContext())
// Given config, grab a map of the possible options for the select custom field
def options = optionsManager.getOptions(config)
selectField.setFieldOptions(options.collectEntries{[(it.optionId): it.value]})
This seems to work for Create Issue and Edit Issue screens and the None option is indeed removed from the list of choices. However, when I try to do inline edit on the field, the None option is still there.
I'm hoping someone can chime in and tell me what I am doing wrong here.
I'd greatly appreciate any help I can find.
Many thanks,
Kamran