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

Remove 'None' from drop down list of Behaviors required field. I've already looked at all the answers here...

Matt Havemann August 9, 2016

I have a field that I set to Required via the Behaviors plugin so the None option isn't automatically removed. I do not want it to always be required because it's conditional based on other inputs. I've put this code in to the description of the field. However it does not work.

 

<script type="text/javascript">
AJS.$(function() {
var list = document.getElementById('cf-customfield_13231')
list.remove(1)
});
</script>

 

I don't know if it has anything to do with it, but the field in question is set to Hidden unless a radio button field is set to Yes. I've been looking for about 2 hours trying to find my solution but everything I come across either says "set it to required" which I DO NOT want, and the other options shown don't work for me for some reason sad

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
TõnisO
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 9, 2016

From what I remember the None option is removed from a drop-down when you set its default value to something.

JanaW
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 13, 2016

Nope, it is still there:( Thanks though.

0 votes
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 )

This will only control the visibility of your field's option or selection

0 votes
JanaW
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 13, 2016

I tried the script too and it didn't work either prior to posting this question. Very frustrating.

0 votes
JanaW
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 4, 2016

I am struggling with this myself. Do not want to make the custom field "required". I did set the default value to something other than none and NONE is still available in the dropdown.

JanaW
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 13, 2016

That is what I did as a workaround:)

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events