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
Community moderators have prevented the ability to post new answers.
From what I remember the None option is removed from a drop-down when you set its default value to something.
Nope, it is still there:( Thanks though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried the script too and it didn't work either prior to posting this question. Very frustrating.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is what I did as a workaround:)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.