This script is used as a post function to change the priority of an issue based on a single-select field.
Example
As a product manager, I have many issues with a single-select custom field called 'affects'. This custom field has many options. I want to assign a priority to the issue depending on the select value.
Good to know
This post function should be the first function in your transition, not the last!
//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
//Assign priority depending on the custom field value switch (customFieldVal?.value) { case "Audit (Internal)": issue.setPriorityId(highestPriority.id) break case "Audit (External)": issue.setPriorityId(highPriority.id) break default: log.debug "No need to change the priority" break }