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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

64 views 0 5
Read article

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