Hello Team,
Is it possible to change priority (a custom field value) based on their choice for another field vlue, Users Affected (custom field). Below code is working on System "Priority" value, but not on "Priority" custom field value. Could you please help how to implement this.
For example, if somebody submits a ticket with 'All Users Affected' selected for Users Affected the ticket is automatically made a custom field "Priority" is Blocker.
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjects(issue)?.find { it.id == "customfield_15405" } // User Affected custom field id.
def customFieldVal = issue.getCustomFieldValue(customField)
def blockerPriorityID = "1" // Blocker
def criticalPriorityID = "2" // Critical
def majorPriorityID = "3" // Major
def minorPriorityID = "4" // Minor
def trivialPriorityID = "5" // Trivial
switch (customFieldVal) {
case "All Users Affected":
issue.setPriorityId(blockerPriorityID)
log.debug("Set priority to Blocker")
break
case "Multiple Users Affected":
issue.setPriorityId(criticalPriorityID)
log.debug("Set priority to Critical")
break
case "One User Affected":
issue.setPriorityId(minorPriorityID)
log.debug("Set priority to Minor")
break
default:
log.debug("No need to change the priority")
break
}