Hide/enable Checkbox based on Yes or No upon a custom field value selection

Andrew April 13, 2021

Hello all,

I have a requirement of enabling/making visible a checkbox field after a custom field value is selected  from another field.

Once the Check box is visible  with "Yes" and "No" as options.  The user selects Yes then No checkbox should be hidden if he wants to switch unchecking the yes should bring back both for selection.

Need some help in Scripting the behavior so that the checkbox is visible after the custom field selection.

I have the code example found in the forum for the selection of yes or no but couldn't bring back the No after it gets hidden.

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
def customField = getFieldById(fieldChanged)

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(fieldChanged)
def optionsManager = ComponentAccessor.getOptionsManager()

//Get list of options tied to the custom field
def options = optionsManager.getOptions(cf.getRelevantConfig(issueContext))

//Filter option list with the condition specified
def optionsMap = options.findAll {

//set your conditions, to filter the option list
it.value == "Yes"

}

//Set the filtered optionsMap to the custom field
customField.setFieldOptions(optionsMap)

 

appreciate your help.

 

 

1 answer

0 votes
Andrew April 13, 2021

Field design as below

image.png

Suggest an answer

Log in or Sign up to answer