Jira Software 9.0.0 (Server/On-Premise) and MyGroovy 1.22.1-jira8 plugin.
I have a use case where I want to prevent workflow transition using validator if user's non-response to custom field 1) is not captured or default value selected and if user's response is 2) a value other than "No". Custom field is a radio type custom field with options: "None" (default), "No", and "Yes".
Using Groovy inline script getting two errors:
"Cannot find matching method com.atlassian.jira.issue.mutableissue#getCustomFieldValue(long). Please check if the declared type is correct and the method exists." on line 9.
"Cannot find matching method java.lang.Object.getCustomFieldValue(java.lang.Object). Please check if the declared type is correct and the method exists." on line 18.
I've successfully solved for 1) above, so really looking for input on 2) - see script below.
New to this, so any help is appreciated - what am I missing?
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def CUSTOM_FIELD_ID = 12345L
def MESSAGE_ERROR = "Field ${getCustomFieldObject(CUSTOM_FIELD_ID)} is required"
def cFieldValue = issue.getCustomFieldValue(CUSTOM_FIELD_ID).getValue()
return cFieldValue
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)
}
if (cFieldValue == "Yes") {
throw new InvalidInputException("Epic cannot transition because Yes response selected - click Cancel")
}
