Skip to content

Instantly share code, notes, and snippets.

@jechlin
Created March 23, 2014 12:57
Show Gist options
  • Save jechlin/9722736 to your computer and use it in GitHub Desktop.
Save jechlin/9722736 to your computer and use it in GitHub Desktop.
package examples.usermgr
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.InvalidInputException
/* CONFIGURABLE SECTION */
def parentGroupFieldName = "Parent Group"
def childGroupFieldName = "Child Group"
/* END CONFIGURABLE SECTION */
def customFieldManager = ComponentAccessor.getCustomFieldManager()
Issue issue = issue
def customFields = customFieldManager.getCustomFieldObjects(issue)
[parentGroupFieldName, childGroupFieldName].each {fieldName ->
def field = customFields.find { it.name == fieldName }
assert field // fields not found or not associated with issue
if (! issue.getCustomFieldValue(field)) {
throw new InvalidInputException("Please enter both $parentGroupFieldName and $childGroupFieldName")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment