Full disclosure, I am new to ScriptRunner and Groovy scripting, however I have scripting experience in other languages.
As the title says, I want to set the value of Field B based on what is selected in Field A. We're doing this in another behaviour, so I have stolen the code and changed the relevant field names to match the ones I need. I'm trying to determine if the result is a bug, or if I'm missing something.
What happens is upon selecting an option in Field A, Field B changes from "None" to just nothing. If you click the drop down menu, the desired option is the only one available. Here is my code:
// Import classes needed
import com.atlassian.jira.component.ComponentAccessor
def optionsManager = ComponentAccessor.getOptionsManager()
// Get CFs and create options manager
def subCategory = getFieldByName("Sub-Category Local").getValue() as String
def categoryRF = getFieldByName("Category RF")
def customField = customFieldManager.getCustomFieldObject(categoryRF.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
// Checks Sub-Category and sets Category RF options
if(subCategory == "Conversion costs (cups)")
{
categoryRF.setFieldOptions(options.findAll {it.value in ['Plastics']})
}
Here are screen shots of what is displayed after making the selection.


Like I said, this code was taken from another behaviour we have that does the same thing for another project, I've just changed the fields.