Skip to content

Instantly share code, notes, and snippets.

@jechlin
Created July 15, 2013 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jechlin/6003129 to your computer and use it in GitHub Desktop.
Save jechlin/6003129 to your computer and use it in GitHub Desktop.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Logger
def log = Logger.getLogger("com.onresolve.jira.groovy.MyScript")
def MutableIssue issue = issue
log.debug(issue)
def fieldName = "My Multi Checkboxes" // Change name of custom field
def optionValue = "Maybe" // Name of option value
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
if (issue.priorityObject.name == "Blocker") {
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == fieldName}
if (cf) {
def fc = cf.getRelevantConfig(issue)
def option = optionsManager.getOptions(fc).getRootOptions().find {it.value == optionValue}
if (option) {
issue.setCustomFieldValue(cf, [option])
}
else {
log.warn("Could not find option with value \"$optionValue\"")
}
}
else {
log.warn ("CF $fieldName was not associated with this issue")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment