This piece is with regards to a Severity Matrix for our customer raised issues.
The following works fine via a script runner post function
import com.atlassian.jira.component.ComponentAccessor
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Severity")
def cfConfig = cfSelect.getRelevantConfig(issue)
def ImpactField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10222")
def ImpactValue = (String)issue.getCustomFieldValue(ImpactField);
log.info("Priority:" + issue.priority.name )
log.info("Impact:" + ImpactValue )
def SeverityID = '0'
def IssueSeverity = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.toString() == SeverityID
}
if (ImpactValue == "Company (All)") {
if (issue.priority.name == "Critical") { SeverityID = '1'}
if (issue.priority.name == "Major") { SeverityID = '2'}
if (issue.priority.name == "Minor") { SeverityID = '3'}
}
if (ImpactValue == "Department (more than 1)") {
if (issue.priority.name == "Critical") { SeverityID = '2'}
if (issue.priority.name == "Major") { SeverityID = '2'}
if (issue.priority.name == "Minor") { SeverityID = '3'}
}
if (ImpactValue == "Individual") {
if (issue.priority.name == "Critical") { SeverityID = '3'}
if (issue.priority.name == "Major") { SeverityID = '3'}
if (issue.priority.name == "Minor") { SeverityID = '3'}
}
IssueSeverity = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {
it.toString() == SeverityID
}
log.info("Severity Set To:" + SeverityID )
issue.setCustomFieldValue(cfSelect, IssueSeverity)
This works a treat on issue creation. This is saved as a file in the script editor within Scriptrunner.
Now we need this to run whenever the Priority or Impact fileds are changed, my first attempt with a ScriptRunner Listner does not seem to work, though it appears to running the file.

