I am working on a POC to demonstrate field behavior modification by suing the behavior module of Scriptrunner
I am trying to limit the option values for this single selection custom filed “SelectBehavior”
I have created a behavior and mapped it to my project and issue types
I have the following code in the initializer section of the behavior and also added the field SelectBehavior to the behavior
But when I create a new “Test Defect” I don’t see any change in the drop down value for the field SelectBehavior
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def FormField formField = getFieldByName("SelectBehavior")
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsMap = options.findAll {
it.value in ["None","Two"]
[
(it.optionId.toString()) : it.value
]
}
String issueType = issue.issueType.name
if (issueType.equals("Test Defect"))
{ log.info "behavior good"
formField.setFieldOptions(optionsMap)
formField.setRequired(true)
}