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?
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
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")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.