Setting a select list field when a select list is changed to a certain value with Listener Edited

 

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option

def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def escalatedField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Escalated"}
def urgencyField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Urgency"}
def changeHolder = new DefaultIssueChangeHolder()
def urgencyValue = issue.getCustomFieldValue(urgencyField)
if 	(urgencyValue in ["Medium"])
	{	OptionsManager optionsManager = ComponentAccessor.getOptionsManager()
		def cfValue = optionsManager.getOptions(escalatedField.getRelevantConfig(issue)).getOptionForValue("Yes",null)
		escalatedField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(escalatedField), cfValue ),changeHolder)
	}

Code is above. The checkbox field (escalatedField) is set when I do not add the if statement: if (urgencyValue in ["Medium"])

 

 

Any assistance would be appreciated!

 

1 answer

It works when I do

String urgencyValue = issue.getCustomFieldValue(urgencyField)

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,123 views 6 19
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
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