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.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

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

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
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
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

684 views 1 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