Using ScriptRunner Behaviours on Jira Server. I have a drop down field that I'm using where I want the checkbox field to show or hide dependent on the selection as well as update the options for the checkbox and make the checkboxes required or not required. The checkbox options is working, making the checkboxes required works. The hide and show is not working. If I remove the code to set the options, the hide/show works fine. Looking for a little direction here. Thanks in Advance. Note it should hide the policySymbols field when area field is N/A and show it for all other selections.
Areas is the drop down and policySymbols is the checkbox field. I have the script on the areas field.
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def policySymbols = getFieldByName("Policy Symbols")
def area = getFieldByName("Area")
def customField = customFieldManager.getCustomFieldObject(policySymbols.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def areaVal = area.getValue()
if (areaVal == "All") {
def optionsMap = options.findAll {
it.value in ["CL-BP", "CL-CA", "CL-CPP", "CL-CT", "CL-CUP", "CL-DO", "CL-EO", "CL-EPL", "CL-F", "CL-FO", "CL-FUP", "CL-GLA", "CL-IMP", "CL-OE", "CL-SCP", "CL-WCP", "CL-XA", "CL-XMP", "CL-XPP", "PL-AHP", "PL-AR", "PL-DF", "PL-FA", "PL-FP", "PL-GH", "PL-HM", "PL-HO", "PL-IM", "PL-MA", "PL-MC", "PL-MH", "PL-NSA", "PL-PA", "PL-PA3", "PL-PLH", "PL-PPT", "PL-PRH", "PL-SH", "PL-TH"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
policySymbols.setFieldOptions(optionsMap)
policySymbols.setRequired(true)
policySymbols.setHidden(false)
}
else if (areaVal == "Commercial Lines") {
def optionsMap = options.findAll {
it.value in ["CL-BP", "CL-CA", "CL-CPP", "CL-CT", "CL-CUP", "CL-DO", "CL-EO", "CL-EPL", "CL-F", "CL-FO", "CL-FUP", "CL-GLA", "CL-IMP", "CL-OE", "CL-SCP", "CL-WCP", "CL-XA", "CL-XMP", "CL-XPP"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
policySymbols.setFieldOptions(optionsMap)
policySymbols.setRequired(true)
policySymbols.setHidden(false)
}
else if (areaVal == "Personal Lines") {
def optionsMap = options.findAll {
it.value in ["PL-AHP", "PL-AR", "PL-DF", "PL-FA", "PL-FP", "PL-GH", "PL-HM", "PL-HO", "PL-IM", "PL-MA", "PL-MC", "PL-MH", "PL-NSA", "PL-PA", "PL-PA3", "PL-PLH", "PL-PPT", "PL-PRH", "PL-SH", "PL-TH"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
policySymbols.setFieldOptions(optionsMap)
policySymbols.setRequired(true)
policySymbols.setHidden(false)
}
else if (areaVal == "N/A") {
def optionsMap = options.findAll {
it.value in ["N/A"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
policySymbols.setFieldOptions(optionsMap)
policySymbols.setRequired(false)
policySymbols.setHidden(true)
}