Created
July 15, 2013 20:25
-
-
Save jechlin/6003129 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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