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

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

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 Join to answer
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 ...

2,760 views 11 18
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