Set radio button custom field is not working Edited

Hi,

I'm trying to update a radio button custom field with one of the values in this field using post-function in a specific transition.

I wrote the following groovy script:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import static groovy.io.FileType.FILES


import org.apache.log4j.Logger
import org.apache.log4j.Category

def Category log = Category.getInstance("com.onresolve.jira.groovy.Condition")
log.setLevel(org.apache.log4j.Level.DEBUG)

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()


def cField = customFieldManager.getCustomFieldObject('customfield_13899') //Confirm Bundle use - custom field
def cFieldValue = issue.getCustomFieldValue(cField) as String
def cField2 = customFieldManager.getCustomFieldObject('customfield_13893') //Bundle changes - custom field
def cFieldValue2 = issue.getCustomFieldValue(cField2) as String


log.info("The Bundle change current value is: "+ cFieldValue2)

if (cFieldValue=="Using Bundle as is") {
def changeHolder = new DefaultIssueChangeHolder()
cField2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cField2), "Bundle with no changes"),changeHolder)
//log.info("Need to write using Bundle as is")
} else if (cFieldValue=="Pulling additional algorithmic trees into an existing Bundle") {
def changeHolder = new DefaultIssueChangeHolder()
cField2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cField2), "Bundle change requested"),changeHolder)
//log.info("Need to write bundle change requested")
}

 

My goal is to update the radio button custom field - cField2 with a specific value depending on the value in the custom field - cFieldValue.

Do you know why the radio button custom field is not updating?

 

 

Thanks,

Bar

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Opsgenie

Getting the Most out of Atlassian and Opsgenie Together

We’re excited to invite you to this action-packed webinar where we will demonstrate how to integrate Opsgenie’s powerful alerting and on-call management tools with your entire Atlassian stack. Mar...

63 views 0 0
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