Is it possible to use a Scriptrunner customer field to modify the behaviour between two select list custom fields.
I would like to achieve something like the following:
Custom Field 1 value = 1
Custom Field 2 value dynamically populates options = A, B, C
Custom Field 1 value = 2
Custom Field 2 value dynamically populates options = D, E, F
I would like to avoid using a Cascading Select custom field, because you can't report off it as you can with an individual custom field.
Is this possible? I have tried to look at similar topics and have struggled to find something close to this.
Best wishes
Adam
Edit: On reading this advice, I have tried to do this using behaviours, but still no joy with the following script. It simply doesn't seem to change the view of options, no matter what I am selecting in the checkBox.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
// Point towards Change Result Reason custom field list
def selectList = getFieldById("customfield_15601")
// Point towards Change Result custom field list
def checkBox = getFieldById("customfield_15600")
// Get access to the required custom field and options managers
def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
// Get the checkbox option value as a String
def checkBoxVal = checkBox.getValue()
// Logic to do some actions depending on what check box value is selected
if (checkBoxVal == "Successful") {
// define and set the required options when checkbox A is selected
def optionsMap = options.findAll {
it.value in ["Implemented Successfully"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)
} else if (checkBoxVal == "Partially Successful") {
// define and set the required options when checkbox A is selected
def optionsMap = options.findAll {
it.value in ["Bug", "Compatibility Issue", "Configuration Issue", "Deployment Failure", "Did Not Address Reason for Change", "Human Error", "Infrastructure Failure", "Incomplete CHG", "Incomplete documentation", "Management/Business Request", "Methodology not understood or tested", "Other", "Successful", "Testing Failure"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)
} else if (checkBoxVal == "Unsuccessful") {
// define and set the required options when checkbox A is selected
def optionsMap = options.findAll {
it.value in ["Bug", "Compatibility Issue", "Configuration Issue", "Deployment Failure", "Did Not Address Reason for Change", "Human Error", "Infrastructure Failure", "Incomplete CHG", "Incomplete documentation", "Management/Business Request", "Methodology not understood or tested", "Other", "Successful", "Testing Failure"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)
}
What type of reporting are you trying to do that you cant with the cascading select list custom field? It might be easier to script against a cascading select than to re-invent it.
Thanks Randy, in the end I just got around it by using two separate select list custom fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.