Hi,
I found this script and I am trying to adapt it to my needs and add it as a post function to the create step in my workflow so that when an issue is logged, it looks at a field and then updates the priority accordingly.
Custom Field - Cyber Incident Categorisation with the following options:
Account Compromise - P1
Host Compromise - P2
Phishing - P3
Denial of Service - P4
Extortion (Ransomware) - P5
Insider Threat - P1
Data Loss & Compromise - P2
Script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
final customFieldName = "Cyber Incident Categorisation"
//Get custom field issue with this name
def customFieldManager = ComponentAccessor.customFieldManager
def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField: "Could not find custom field with name $customFieldName"
def customFieldVal = issue.getCustomFieldValue(customField) as LazyLoadedOption
//Create priorities
def priorities = ComponentAccessor.getComponent(PriorityManager).priorities
def highestPriority = priorities.findByName("P1")
def highPriority = priorities.findByName("P2")
assert highestPriority && highPriority: "One ore more selected priorities doesn't exist"
--- I actually need this to go up until P5 so would the additional priorities need to be added on and defined as such as medium, lower, lowest?
//Assign priority depending on the custom field value
switch (customFieldVal?.value) {
case "Account Compromise":
issue.setPriorityId(highestPriority.id)
break
case "Host Compromise":
issue.setPriorityId(highPriority.id)
break
default:
log.debug "No need to change the priority"
break
}
Any help would be appreciated.
Thanks.