I'm trying to set options to a Priority field using behaviours. I need to set High, Critical, Regular and Low priority and do not change the priority scheme for project.
I am having trouble getting my code to work.
Here's my current behaviour script:
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
final singleSelectListName = 'SingleSelectList'
[singleSelectListName].each { selectFieldName ->
// Get the select field
def selectField = getFieldByName("priority")
// Getting select field options
def selectCustomField = customFieldManager.customFieldObjects.findByName(selectFieldName)
def selectConfig = selectCustomField.getRelevantConfig(issueContext)
def selectOptions = ComponentAccessor.optionsManager.getOptions(selectConfig)
// Filter select available options
final selectAvailableOptions = selectOptions.findAll { it.value in ['10200', '2', '6', '10202'] }
selectField.setFieldOptions(selectAvailableOptions)
// Set the default values depending on select type
if (selectFieldName == singleSelectListName) {
def defaultValue = selectAvailableOptions.find { it.value in ['10200', '2', '6', '10202'] }
selectField.setFormValue(defaultValue.optionId)
}
}