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 Join to comment
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,198 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot