Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,228
Community Members
 
Community Events
184
Community Groups

How to remove the option "none" from select fields?

So currently I'm using Jira Cloud to set a few screens and my current issue is that even by setting a default value or by making a field required, the "None" option still shows up as being usable (although it makes you change it if you try to continue).

What I currently need is to completely remove the "None" option from both Cascading select field and Single line select fields.

3 answers

may be it will help

import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.component.ComponentAccessor


def optionsManager = ComponentAccessor.getComponent(OptionsManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def state =getFieldById("customfield_XXXXX")
def stateValue = state.getValue() as String

def country = getFieldById("customfield_XXX")
def countryValue = country.getValue()

 

def selectCustomField = customFieldManager.getCustomFieldObjectByName("Country")
def selectConfig = selectCustomField.getRelevantConfig(getIssueContext())
def selectOptions = optionsManager.getOptions(selectConfig)


def selectAvailableOptions1 = selectOptions.findAll { it.value in ["India"]}
def selectAvailableOptions2 = selectOptions.findAll { it.value in ["India", "USA"]}
def selectAvailableOptions3 = selectOptions.findAll { it.value in ["India", "USA", "Australia"]}

// cf.setFieldOptions(selectAvailableOptions)
boolean Country1 = false
boolean Country2 = false
boolean Country3 = false
String[] matches1 = new String[] {"Andhra Pradesh", "Madhya Pradesh", "Karnataka", "Tamil Nadu", "Telangana"};
String[] matches2 = new String[] {"Alaska", "California", "Texas"};
String[] matches3 = new String[] {"New South Wales", "Queensland", "South Australia"};

for (String s : matches1)
{
if (stateValue.contains(s))
{
Country1 = true
}
}

for (String s : matches2)
{
if (stateValue.contains(s))
{
Country2 = true
}
}

for (String s : matches3)
{
if (stateValue.contains(s))
{
Country3 = true
}
}

/*
if (Country1 == true || Country2 == true || Country3 == true ){
//country.setFormValue(['Inida', 'USA', 'Australia'])
country.setFieldOptions(selectOptions.findAll { it.value != -1})
}
*/
if (Country1 != true && Country2 != true && Country3 != true ){
//country.setFormValue(['Inida', 'USA', 'Australia'])
country.setFieldOptions(selectOptions.findAll { it.value in ['India', 'USA', 'Australia']})
}
if (Country1 == true && Country2 == true && Country3 == true ){
//country.setFormValue(['Inida', 'USA', 'Australia'])
country.setFieldOptions(selectOptions.findAll { it.value in ['India', 'USA', 'Australia']})
}
else if (Country1 == true && Country2 == true && Country3 != true){
//country.setFormValue(['Inida', 'USA'])
country.setFieldOptions(selectOptions.findAll { it.value in ['India', 'USA']})
}
else if (Country1 == true && Country2 != true && Country3 == true){
//country.setFormValue(['Inida', 'Australia'])
country.setFieldOptions(selectOptions.findAll { it.value in ['India', 'Australia']})
}
else if (Country1 != true && Country2 == true && Country3 == true){
//country.setFormValue(['USA', 'Australia'])
country.setFieldOptions(selectOptions.findAll { it.value in ['USA', 'Australia']})
}

else if (Country1 == true && Country2 != true && Country3 != true){
//country.setFormValue(['Inida'])
country.setFieldOptions(selectOptions.findAll { it.value in ['India']})
}
else if (Country1 != true && Country2 == true && Country3 != true){
//country.setFormValue(['USA'])
country.setFieldOptions(selectOptions.findAll { it.value in ['USA']})
}
else if (Country1 != true && Country2 != true && Country3 == true){
//country.setFormValue(['Australia'])
country.setFieldOptions(selectOptions.findAll { it.value in ['Australia']})
}

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 14, 2021 • edited

Welcome to the Atlassian Community!

One quick thing - you say "by setting a default value or by making a field required" - that should be an "and", not an "or".  If you set a default value and make the field required, none will go away.  People will be presented with the defualt pre-selected and no "none" on the list.

However, this does not apply to the second half of a cascading-select list.

Hey @Nic Brough -Adaptavist- My bad there, but I've tried doing both one by one and doing both at the same time. the field None is still there, not selected, but can be clicked on.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 15, 2021

So, if for a select list, you have set a default, and made the field mandatory, then "none" will only be on the list if you have added an option called "none".  Check the list of options for the field, you'll find None is an option.

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 14, 2021

Hi @ivan.lose and welcome to the community,

Usually select fields comes with the None options. To overcome this problem a solution would be to make this field required within the field configuration. I would pay extra attention before configuring this, and make sure that the field configuration is not shared and/or the modification you'll make, will not affect other projects. 

Hey  @Alex Koxaras _Relational_  and thanks for the warm welcome

But as I've mentioned before, I've tried making it required, and it still shows None as an option. It won't allow you to go through with the ticket without completing it, unless this is the second field on a cascading one, which has been pretty much my issue as well.

I've been told that groovy script runner is the way to go, but almost every solution is for Jira Server, and therefore won't work in Cloud.

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 14, 2021

@ivan.lose my bad! I didn't read carefully :)

However, I did manage to hide the NONE in a single select field and I did exactly what you tried:

  • Created a new field configuration and made my single select required
  • Created a new field configuration and use the field config for the issue types I wanted
  • I associated this field config scheme with my project
  • I went to my custom field and edit the default value to any other but None
  • Voila

single select.png

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 14, 2021

However the above solution doesn't seem to work in cascading fields.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 14, 2021

No, the "mandatory" check only checks if the cascading select has any value, which it does if only the first half is set.

There's an open request to get the logic changed to "both parts"

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 14, 2021 • edited

Hey @Nic Brough -Adaptavist- it looks like along with the problem of Cascading Fields not forcing the secondary value to be selected (which is a separate issue), it appears that "None" still shows up even if it's required and has a default selected, per JRACLOUD-32463

Description:

Currently, when making a cascading select list which has a default designated a required field, the none option is still present and an acceptable value.

The behavior for this should mimic the select list where the none option is removed once the cascading select is set to required and has a default set.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 14, 2021

Yep, that's the one for Cloud, there's another request for server that's older (pre Cloud!) if memory serves.

Now, my question comes for both types of drop down lists. AS I want to remove the "none" option from both cascading and single select lists. and making it required and with a default value doesn't seem to be the solution

Regarding my cascading select list:

The below JQL will work to find the issues when the child is empty: 
project = TEST and "Environment/Test Type[Select List (cascading)]" = is not Empty AND "Environment/Test Type[Select List (cascading)]" not in ("DR (Disaster Recovery) Test", "Performance Test", "Regression Testing", "Security Testing", "Unit Test", "User Acceptance Testing", Integration).

Anyone know of a more concise way to write the bolded part of the JQL that will work? Please keep in mind that None is the Jira Cloud's native default and I don't want to make this field required due to other integrations. I've tried to use is empty, is blank, is null, = none...none of that worked.

If no more eloquent way is available, I can go with what I have.

Thanks Community!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events