Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to validate the existence of several custom fields on transition using the ScriptRunner plugin for Jira.
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
def customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
def fields = []
// For Alma issues, if issue is fixed, make all sorts of validations
if (issue.resolution?.name == 'Fixed' && issue.project?.name == 'Alma') {
switch ( issue.issueType?.name ) {
case 'Bug':
fields.addAll(['Resolution Description','Fix in Environment'])
case ['Story', 'Bug', 'Task', 'inList']:
fields.addAll(['Documentation Required','Migration Impact','Configuration Impact','Automation Impact','Leganto Documentation Required'])
fields.each {
CustomField cf = customFieldManager.getCustomFieldObjectByName(it)
if (cf && !issue.getCustomFieldValue(cf)) {
if (invalidInputException)
invalidInputException.addError(, "You must specify a value for ${}.")
invalidInputException = new InvalidInputException(, "You must specify a value for ${}.")
if (invalidInputException)
invalidInputException.addError("The fields marked below must be filled before the issue can be resolved.")
} else
return true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.