how to display custom field value based on another custom field value in jira

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
}

0 comments

Comment

Log in or Sign up to comment
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

241 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you