Hi All,
Newbie here, struggling to putting together working script after several hours of attempted learning and forum research.
Jira Software Server 9.0.0 (On-Premise) and Groovy Scripting.
Goal: prevent user from transitioning an issue forward in workflow if selected value from among aerial options ("Yes", "No" or the default "None") for custom field is set to "Yes".
Here's the code block so far... bolded/italicized code is where I've been unsuccessful.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.issue.fields.CustomField
def CUSTOM_FIELD_ID = 10405L
def MESSAGE_ERROR = "Field ${getCustomFieldObject(CUSTOM_FIELD_ID)} is required"
if(getCustomFieldValue(issue, CUSTOM_FIELD_ID).name == "Yes"){
throw new InvalidInputException("Response cannot be "Yes", click Cancel")
}
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)
}
Above script is successful in blocking transition when there is not a custom field value entered by user (i.e., "None"), but again, having huge time in attempting to solve for also blocking transition if user chooses/selects "Yes" and tries to move issue forward in workflow.
Any help or input is very appreciated!