Why are my checkbox field options not mutually exclusive?

Phil Bustin June 2, 2022

After adding Checked and Unchecked options to a custom checkbox field, wondering why the options aren't mutually exclusive, and posting that question to the Community (this post), I realized that the field should not have options.  In a different app, checkboxes are binary fields, but I that is not the case in Jira. 

I switched to a radio button, and added one option, so that the button behaves like a binary checkbox--IF I can hide the built-in None option.  Can that be done?

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2022

Hi @Phil Bustin 

Would you please clarify what you are asking/observing?  Thanks!

Checkboxes are normally zero-to-many selections, and Radio Button options are one-and-only-one selections, which matches the custom fields that can be added to Jira: https://confluence.atlassian.com/adminjiracloud/custom-fields-types-in-company-managed-projects-972327807.html

For company-managed projects, there is a known problem for custom field, radio buttons which are configured as required with a default value, as they still show a "none" option when they should not: https://jira.atlassian.com/browse/JRACLOUD-75541

Kind regards,
Bill

Phil Bustin June 3, 2022

Thanks, Bill.  I was asking exactly what you addressed.  I found a possible workaround yesterday to hide 'None'.  Here's an extract from it that I saved:

import com.atlassian.jira.component.ComponentAccessor

//Grab appropriate managers
def cfManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

//Grab form and custom field values
def selectCF = cfManager.getCustomFieldObject("SelectListA")
def selectField = getFieldByName("SelectListA")

//Must grab the relevant config given the current issue context and the custom field
def config = selectCF.getRelevantConfig(getIssueContext())
//Given config, grab a map of the possible options for the select custom field
def options = optionsManager.getOptions(config)

//Define preset multi select options for each single select case
selectField.setFieldOptions(options.collectEntries{[(it.optionId): it.value]})

Of course you'll want to change "SelectListA" in this script to the actual name of your field.

Regards,

Josh

Mattias Kallvi Dec 13, 2018 • edited

Hi Joshua,

Thanks for your script. After a minor change to it (used the field id instead of the field name) it works perfectly. Maybe I have to use id since we have Swedish characters in the field name, not sure. However, this is how thoses lines look now:


//Grab form and custom field values
def selectCF = cfManager.getCustomFieldObject("customfield_12345")
def selectField = getFieldById("customfield_12345")

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events