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
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
Fadoua M. Boualem
Published yesterday in Trello

Using Trello to manage events

As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...

385 views 5 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