Please note that these all transition are closing transition and having different screen
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.config.FieldConfig
// Get the field and issue context
def resolutionCategoryField = getFieldById(getFieldChanged()) // 'Resolution Category' field
def transitionName = actionName // Workflow transition name
// Ensure transition name is captured properly
if (!transitionName) {
log.error("Transition name could not be determined. Make sure this Behaviour is mapped correctly.")
return
}
// Define valid options for each transition
def resolutionOptions = [
"Fixed-No code change": [
"Customer Environment Issue",
"Platform or Collector Issue",
"Documentation Missing or Misleading"
],
"Won't Do": [
"Product Enhancement",
"Technical Limitation"
],
"Invalid": [
"Not Reproducible",
"Failed Quality Bar",
"Working as Designed"
],
"No Response": [
"Internal No Response",
"External No Response",
"Devices No Response",
"Customer No Response"
]
]
// Get the valid options for the current transition
def validOptions = resolutionOptions[transitionName] ?: []
// Fetch the configured options for the field
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def resolutionCategoryCf = customFieldManager.getCustomFieldObject(resolutionCategoryField.getFieldId())
if (!resolutionCategoryCf) {
log.error("Could not fetch the Resolution Category field.")
return
}
FieldConfig config = resolutionCategoryCf.getRelevantConfig(underlyingIssue)
def allOptions = optionsManager.getOptions(config)
// Filter options based on the transition
def filteredOptions = allOptions.findAll { it.value in validOptions }
// Update the field's options
if (filteredOptions) {
resolutionCategoryField.setFieldOptions(filteredOptions)
} else {
resolutionCategoryField.setFieldOptions([]) // If no valid options, clear the field
}