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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

243 views 1 18
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