Can you tell me if it is possible to make a choice of the value of other fields based on Resolution value?
I was able to do this for Resolve but I can't figure out why it doesn't work for Edit screen
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.context.IssueContext
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.issue.resolution.Resolution
@BaseScript FieldBehaviours fieldBehaviours
java.lang.Iterable allowedOptions = null
java.lang.Iterable allowedOptions2 = null
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
//final String dea_result = 'DEA Result'
//final String root_cause = 'Root Cause'
def root_cause = getFieldByName('Root Cause')
def root_cause_cf = customFieldManager.getCustomFieldObjectByName('Root Cause')
def dea_result = getFieldByName('DEA Result')
def dea_result_cf = customFieldManager.getCustomFieldObjectByName('DEA Result')
def res_f = getFieldById("resolution")
def res = res_f.getValue() as Resolution
def config = root_cause_cf.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def config2 = dea_result_cf.getRelevantConfig(getIssueContext())
def options2 = optionsManager.getOptions(config2)
if (getActionName() == "Resolve")
{
if (res.name.toString() == 'Fixed')
{
allowedOptions = null
allowedOptions2 = null
allowedOptions = options.findAll {
it.value in ["Development issue - Functional", "Development issue - Integration", "Firmware/Third Party", "Lack of Requirements", "Merge", "Not a bug - Broken Environment"]
}
allowedOptions2 = options2.findAll {
it.value in ["Broken Environment", "Test Environment Limitation", "Emulator/Mockup issue", "Deployment Instructions issue", "Known issue", "Floating issue", "No Requirements", "Late Requirements Change", "Wrong Requirements", "No Test Case", "Outdated Test Case", "Wrong Test Case", "Not tested (TC not needed)", "Existing TC wasn't executed", "Caused by late merge/fix", "3rd party issue", "Specific scenario", "TC Execution mistake", "TC Execution blocked"]
}
root_cause.setFieldOptions(allowedOptions)
dea_result.setFieldOptions(allowedOptions2)
}
else if (res.name.toString() == "Won't Fix")
{
allowedOptions = null
allowedOptions2 = null
allowedOptions = options.findAll {
it.value in ["Development issue - Functional", "Development issue - Integration", "Firmware/Third Party", "Lack of Requirements"]
}
allowedOptions2 = options2.findAll {
it.value in ["Known issue", "Floating issue", "No Requirements", "Late Requirements Change", "Wrong Requirements", "3rd party issue"]
}
root_cause.setFieldOptions(allowedOptions)
dea_result.setFieldOptions(allowedOptions2)
}
else if (res.name.toString() == "Not A Bug")
{
allowedOptions = null
allowedOptions2 = null
allowedOptions = options.findAll {
it.value in ["Not a bug", "Not a bug - Outdated Test Case"]
}
allowedOptions2 = options2.findAll {
it.value in ["Not a Bug"]
}
root_cause.setFieldOptions(allowedOptions)
dea_result.setFieldOptions(allowedOptions2)
}
else if (res.name.toString() == "Cannot Reproduce")
{
allowedOptions = null
allowedOptions2 = null
allowedOptions = options.findAll {
it.value in ["Unknown"]
}
allowedOptions2 = options2.findAll {
it.value in ["Floating issue"]
}
root_cause.setFieldOptions(allowedOptions)
dea_result.setFieldOptions(allowedOptions2)
}
else if (res.name.toString() == "Duplicate")
{
allowedOptions = null
allowedOptions2 = null
allowedOptions = options.findAll {
it.value in ["Duplicate"]
}
allowedOptions2 = options2.findAll {
it.value in ["Duplicate"]
}
root_cause.setFieldOptions(allowedOptions)
dea_result.setFieldOptions(allowedOptions2)
}
}
Welcome to the Atlassian Community!
Could it be that the resolution field is not on the edit screen?
It should only ever be put on transition screens.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.