Skip to content

Instantly share code, notes, and snippets.

@chuikoaleksandr
Created November 13, 2018 14:21
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 chuikoaleksandr/76933a73e8abf36016875b368c46990f to your computer and use it in GitHub Desktop.
Save chuikoaleksandr/76933a73e8abf36016875b368c46990f to your computer and use it in GitHub Desktop.
Jira MyGroovy simple validator custom field example
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def CUSTOM_FIELD_ID = 14910L
def MESSAGE_ERROR = "Field ${getCustomFieldObject(CUSTOM_FIELD_ID)} is required"
if(!getCustomFieldValue(issue, CUSTOM_FIELD_ID)){
throw new InvalidInputException(MESSAGE_ERROR)
}
def getCustomFieldValue(issue, Long fieldId) {
issue.getCustomFieldValue(getCustomFieldObject(fieldId))
}
def getCustomFieldObject(Long fieldId) {
ComponentAccessor.customFieldManager.getCustomFieldObject(fieldId)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment