I had a requirement to remove the None option from several fields, to increase screen estate and make the display screens more graceful.
Quite a few answers out there which also match the same mechanism being used here, ScriptRunner Behaviours. However most answers I found required the script author to explicitly list the values that should be displayed. While this does achieve the same end goal it is getting all options excluding none, not actually removing none.
What happens if me or a future system admin adds additional options to the fields, they will not show and the behaviours will have to hunted down, modified, and tested. Additionally, if we wanted to do this with multiple fields, the script can become lengthy and prone to human typos. We've all done it.
My solution has started as a simple behaviour script to remove 'none' from three fields with less lines of scripts and will not require modification when new options are added.
The current script is:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
hideNone("Field 1")
hideNone("Field 2")
hideNone("Field 3")
def hideNone(String FieldName){
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def field = getFieldByName(FieldName)
field.setAllowInlineEdit(true)
def fieldId = customFieldManager.getCustomFieldObject(field.getFieldId())
def fieldConfig = fieldId.getRelevantConfig(getIssueContext())
def fieldOptionsOriginal = optionsManager.getOptions(fieldConfig)
def fieldOptionsCustYes = fieldOptionsOriginal.findAll { it.value !in ["none"] }
field.setFieldOptions( fieldOptionsCustYes )
}