Jira Condition with Groovy

Hide a transition from an issue detail view in Atlassian Jira Software if a condition returns false.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.option.Option
import org.apache.log4j.Level
import org.apache.log4j.Logger
def myLog = Logger.getLogger("Condition Dropdown dependency")
// The select list cf
// In the example the id of the cf select list is 10602
// The option "Stop here" has the id 10200
def cfDropdown =  ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10602)
def cfDropdownValue = issue.getCustomFieldValue(cfDropdown)
def Option cfDropdownOptions = (Option)cfDropdownValue
def cfDropdownValueId = cfDropdownOptions.getOptionId()
// The date picker cf
def cfDatepicker =  ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10601)
def cfDatepickerValue = issue.getCustomFieldValue(cfDatepicker)
// Return false if the date picker cf mandatory hasn't been set
// and the dropdown is set to "Stop here"
def returnValue = true
if (cfDropdownValueId == 10200 && cfDatepickerValue == null) {
  returnValue = false
return returnValue

Install myGroovy

It is free, and an extremely versatile add-on.


Use it together with JSIncluder to inject JavaScript in Jira issues. JSIncluder is from the same group of developers like myGroovy. And it is free, as well.


Further Information




Send me an email for any kind of support related to Atlassian.

More about Groovy in Jira…