Created
November 13, 2018 14:21
-
-
Save chuikoaleksandr/76933a73e8abf36016875b368c46990f to your computer and use it in GitHub Desktop.
Jira MyGroovy simple validator custom field example
This file contains 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.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