Make checkbox custom field options hide/visible depending on selections made in another field.

Hi,

Is it possible to do this and how?

I have two multiple checkbox fields and options as below:

Field1---

---[] a

---[] b

---[] c

Field2---

---[] 1

---[] 2

---[] 3

---[] 4

---[] 5

---[] 6

Field2 options (1,2) are related to Field1 option (a)

Field2 options (3,4) are related to Field1 option (b)

Field2 options (5,6) are related to Field1 option (c)

If I select option "a" from Field1, other than the options 1 and 2 in Field2, every other option should be hidden.

Likewise, If I select options "a" and "b" from Field1, other than options 1,2,3 and 4 every other options should be hidden.

Related options should only be enabled when a selection is made.

It can be possible with jquery or with the behaviours but i don't know how to start . can anyone help me?

Or

Is there any best way to solve this. Any way that we can add a heading to divide the options under the field.

Thanks in advance.

2 answers

This widget could not be displayed.

As a workaround you can have field 1 and three(one for each option of field 1) other multiple checkbox fields which will be displayed if values a, b and c are selected respectively. 

Thanks for the response.

 

Well thats a good Idea.

Field1 is having only 3 options in the scene I explained above.

I am working on the checkbox field which has 61 options. So I was trying to use only two fields instead of having individual fields for each option.

 

This widget could not be displayed.
Found below is one of the similar issues. But it is for change in Select list field.
I have enclosed a code sample below which shows how you can use the Behaviours plugin provided by script runner to dynamically remove and set from a Select List field based on an option selected inside a check box field.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
 
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
 
// Get a pointer to my select list field
def selectList = getFieldByName("Demo Select List")
 
// Get a pointer to my check box field
FormField checkBox = getFieldByName("Check Box 1")
 
// Get access to the required custom field and options managers
def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
 
 
// Get the checkbox option value as a String
def checkBoxVal = checkBox.getValue()
 
// Logic to do some actions depending on what check box value is selected
if (checkBoxVal == "A") {
    // define and set the required options when checkbox A is selected
    def optionsMap = options.findAll {
        it.value in ["A""B"// list of options you want to show
    }.collectEntries {
        [
                (it.optionId.toString()): it.value
        ]
    }
    selectList.setFieldOptions(optionsMap)
else if (checkBoxVal == "B") {
    // define and set the required options when checkbox A is selected
    def optionsMap = options.findAll {
        it.value in ["C""D""E"// list of options you want to show
    }.collectEntries {
        [
                (it.optionId.toString()): it.value
        ]
    }
   selectList.setFieldOptions(optionsMap)
}
Would be great if some one can help me with making it able to setFieldOptions for the Checkbox field. 
Thanks.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

290 views 5 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you