Behaviors: how to make checkbox custom field options hide/visible depending on selected checkboxes inside of the field.

Hi, Folks!
You know, I'm trying to make some checkboxes hidden when I select specific checkboxes of the field.
For example, I have:
"Custom Field" - checkbox type
"A","B","C","D" - the values of this field.
IF I select values "A"&"B" so that values "C" & "D" should be hidden.
How can I solve it is?
Please help me.
Many thanks for advice.

1 answer

1 accepted

This widget could not be displayed.

This isn't really possible through behaviours, its only possible to hide the complete field not specific checkboxes within it. 

Although as a workaround you could use two separate checkboxes and have this script on the checkbox field which contains "A" and "B" and "C" and "D" are on a completely different field. It sounds like they are kind of independent anyway.

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

// this field contains boxes A and B
def checkboxField = getFieldById(getFieldChanged())

// This contains boxes C and D
def otherCheckboxField = getFieldByName("Other Checkbox")

def values = checkboxField.getValue() as List<String>

if (values.containsAll(["A", "B"])) {
    // hide field containing C and D when A and B selected
    otherCheckboxField.setHidden(true)
}

Hi @Adam Markham [Adaptavist], just wanted to clarify:

 

Is it not possible to hide checkbox field options at all, or only in the use case presented in the question?

 

I can use the script below to hide options on a Select field using the Behaviours initializer, but it doesn't work when applied to a checkbox field. I thought they were controlled by same Options classes? Please excuse me if I'm using incorrect nomenclature.

def formField = getFieldByName("Some field");
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId());
def config = customField.getRelevantConfig(getIssueContext());
def options = optionsManager.getOptions(config);

def optionsMap = options.findAll {
    it.value in ["Some option"] 
}.collectEntries {
    [
        (it.optionId.toString()) : it.value
    ]
} 
formField.setFieldOptions(optionsMap);

 

 

  

Do we know if Adaptavist has thise feature in future roadmap to hide options on checkboxes using behaviors ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

514 views 3 18
Read article

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