Created
May 6, 2020 14:54
-
-
Save jechlin-adaptavist/bc452172e50ef21f68ddd1cc0073f661 to your computer and use it in GitHub Desktop.
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
package examples | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.onresolve.jira.groovy.user.FieldBehaviours | |
import groovy.transform.BaseScript | |
@BaseScript FieldBehaviours behaviours | |
def foodField = getFieldById(getFieldChanged()) | |
def subFoodField = getFieldByName('Sub-Food') | |
def customFieldManager = ComponentAccessor.customFieldManager | |
def optionsManager = ComponentAccessor.optionsManager | |
def customField = customFieldManager.getCustomFieldObjectByName('Sub-Food') | |
def config = customField.getRelevantConfig(getIssueContext()) | |
def options = optionsManager.getOptions(config) | |
def newFieldOptions = [] | |
if (foodField.value == [null]) { | |
subFoodField.setFormValue([]).setHidden(true) | |
} else { | |
subFoodField.setHidden(false) | |
} | |
if ('Fruits' in foodField.value) { | |
newFieldOptions.addAll(options.findAll { it.value in ['Apples', 'Bananas', 'Oranges'] }) | |
} | |
if ('Vegetables' in foodField.value) { | |
newFieldOptions.addAll(options.findAll { it.value in ['Spinach', 'Cabbage', 'Cauliflower'] }) | |
} | |
subFoodField.setFieldOptions(newFieldOptions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment