Remove option "None" without requiring the field

Franco C. A. May 28, 2018

Hi, I need to remove the option None everytime I create select lists or radio buttons. I know it can be done through making it required but it affects the whole creation of issues. It is because during creation of issues, my select lists are not yet in the create issue screen therefore I can't proceed to make such.

I found out that it could be achieved without making the field to required if I'll edit the file "edit-select.vm" (C:\Program Files\Atlassian\JIRA\atlassian-jira\WEB-INF\classes\templates\plugins\fields\edit) by this link: 

https://confluence.atlassian.com/jirakb/how-to-remove-none-from-a-select-list-custom-field-144212308.html

however, this solution isn't updated for the current JIRA. By the way I am running the latest version of server (7.9.2) 

Thank you for your time

5 comments

Comment

Log in or Sign up to comment
Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2018

Hi @Franco C. A.

You can use the following javascript to remove the "None" option.

  • Go to Field Config
  • Edit the CF
  • Paste the code
<script type="text/javascript">
AJS.$(function() {
var cfList = document.getElementById('customfield_xxxxx')
cfList.remove(0)
});
</script>

ps: It is also possible to do it via Script Runner (Behaviours) add-on.

Tansu Akdeniz

Like # people like this
Raj Kumar July 15, 2019

Hi @Tansu AkdenizAkdeniz,

Can you please guide how we can do it using script runner.

Thanks,
Raj

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.
June 4, 2018

Why bother?

If you remove "none", you're telling the user that they cannot leave the field empty.  Which is the same as making it mandatory.

Azfar Masut
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.
July 4, 2019

if it's a shared field configuration scheme, you'll need to create another field configuration scheme just for that project. If you have hundreds of projects, you don't want to be creating a field configuration scheme for each of them, with every project has different requirement towards different fields. 

Unless you have a workaround?

Fuad Hasanli October 2, 2019

It's very confusing. Agree with @Azfar Masut. I just need one mandatory field in only one screen. I make it required, affect all process. Even for project creation it becomes required field. I don't want to create another field configuration scheme. I didn't added this field to create screen. 

Azfar Masut
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.
July 4, 2019

Using scriptrunner behavior, you can use something like below. 

Set the field as required/not required (on behavior side, not JIRA's field configuration), depending on your use case.

In my case, I want my severity field to be set as required only on a certain project, without having to create additional field configuration (as I have one massively shared field configuration - for process standard in my company).

So I set the severity field as required through behavior, but the 'none' option stills show. So, use below script :

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def optionsManager = ComponentAccessor.getComponent(OptionsManager)

def severity = getFieldByName("Severity")
severity.setAllowInlineEdit(false)

def sevcustomField = customFieldManager.getCustomFieldObject(severity.getFieldId())
def sevconfig = sevcustomField.getRelevantConfig(getIssueContext())
def sevOptionsOriginal = optionsManager.getOptions(sevconfig)

/*define the select list manually, do not include the 'none'*/
def sevOptionsCustYes = sevOptionsOriginal.findAll { it.value in ['Critical', 'Serious','Medium','Low'] }

severity.setFieldOptions( sevOptionsCustYes )
Like # people like this
Todd Lindsey September 25, 2019

where did you write this script .?

Like Nivida Sharma likes this
Azfar Masut
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.
October 15, 2019

@Todd Lindsey Behavior Script Section in Scriptrunner

Chris Nowaczyk June 29, 2020

That doesnt work.

I did the changes for my problem but I see the "None" Option in every Screen:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def optionsManager = ComponentAccessor.getComponent(OptionsManager)

def dauer = getFieldByName("dauer")
dauer.setAllowInlineEdit(false)

def dauerCustomField = customFieldManager.getCustomFieldObject(dauer.getFieldId())
def dauerConfig = dauerCustomField.getRelevantConfig(getIssueContext())
def dauerOptionsOriginal = optionsManager.getOptions(dauerConfig)

/*define the select list manually, do not include the 'none'*/
def dauerOptionsCustYes = dauerOptionsOriginal.findAll { it.value in ['Critical', 'Serious','Medium','Low'] }

dauer.setFieldOptions( dauerOptionsCustYes )
Diana
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.
August 24, 2022

hello from the future!

Just want to say this script has saved me so much headache! This works on Behaviors and I thank you very very much!

Like Azfar Masut likes this
Clark Everson September 30, 2019

I tried pasting this in the configuration of the field the option remained after i re-index, can't get it to remove and don't have scriptrunner

kala.peethambaran November 28, 2019

Is there any alternative for removing the None option, other than using script ?

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.
November 28, 2019

Make the field mandatory?  As you don't want "none" to be selectable, your people will have to put something into it

TAGS
AUG Leaders

Atlassian Community Events