How to set a customfield checkbox

Hi, I need some pointer in setting a custom field (checkbox). For example: I have a custom field (Track flag) checkbox "Y". I need to enable the checkbox when certain conditions are met. I have the following script but it seems that updateValue is not able to do it. Please help!


import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Category

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.debug "Debug Starts Here..."
log.debug "++++++"

def componentManager = ComponentManager.instance
Issue currIssue = componentManager.getIssueManager().getIssueObject("TESTDEV-787")

def customFieldManager = componentManager.getCustomFieldManager()
def trackFlag = customFieldManager.getCustomFieldObject("customfield_13601")
log.debug "Track flag = " + trackFlag

def fieldConfig = trackFlag.getRelevantConfig(currIssue)
log.debug "Field Config = " + fieldConfig

trackFlagValue = currIssue.getCustomFieldValue(trackFlag)
log.debug "Track flag value = " + trackFlagValue

if (trackFlagValue == null) {
// modifiedValue = new ModifiedValue(trackFlagValue, "Y")
// log.debug "Modified value = " + modifiedValue

log.debug "Enter into here ..."

def changeHolder = new DefaultIssueChangeHolder()
// trackFlag.updateValue(null, currIssue, setFlagValue, changeHolder)
trackFlag.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(trackFlag), "Y"), changeHolder)

log.debug "Debug Ends Here..."

2 answers

This widget could not be displayed.

You may want to debug your script with an IDE like Idea. That answer may be useful for you:

This widget could not be displayed.

Hi Cesare, thanks for getting back to me. I don't have access to the JIRA server to install IDEA. I only have access to the atlassian-jira.log (that's why the DEBUG statements).

I looked into the link you provided but it doesn't show me how to checkoff (enable) the checkbox (Track flag) in my case. Please be more specific. Thanks in advanced.

Hi Caleb, I was referring to my answer at that question (how to debug a script using Idea IDE). Basically you don't need to connect to the server where JIRA is, by starting atlas-debug you will also start your own JIRA instance. With that you can debug every script locally from your machine. The advantage is to have a working test environment to develop and try your scripts without be worried about rights or destroying data. In your case is useful because you can use the IDEA debugger that can give you a lot of infos about what is happening.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

198 views 1 3
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