How to set a customfield checkbox

Caleb Loo February 16, 2015

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.setLevel(org.apache.log4j.Level.DEBUG)
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

0 votes
Caleb Loo February 17, 2015

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.

Cesare Jacopo Corzani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2015

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.

0 votes
Cesare Jacopo Corzani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2015

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

https://answers.atlassian.com/questions/12266875

Suggest an answer

Log in or Sign up to answer