Hi,
I have a single select custom field from which I want to display the first option on the request form instead of none. I am using the below code to have selected options in the custom field this working . But now instead of none I want the first value to be show in the field on request form.
Please help me in fixing this . Your help is highly appreciated.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def Location = getFieldById("customfield_14444")
// Get access to the required custom field and options managers
def customField = customFieldManager.getCustomFieldObject(Location.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsMap = options.findAll {
it.value in ["International",
"United States"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
Location.setFieldOptions(optionsMap)
Thanks,
Raj
Hello,
You do not need scripting. Go to the field configuration scheme (Project settings -> fields) and make this custom field required.
But for few request types I do not display all the options I only display few options.
For example
I have abcd as options in location field and I want to display only ab options on x request form and want a option to be displayed instead of none when I open request form and should be able to change to b while creating a request
. I want to display CD options on y request form and want c option to be displayed instead of none when I open request form and should be able to change to d while creating a request
Thanks,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I gave you an option on how you can get rid of the None option. All other things you can solve with behaviours. I thought your question was about the None option.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have it in many screens I do not want it required in other screens making it required will be a problem.
Without making it required do we have way to solve it using behaviours please advise.
Thanks,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have this field in many screens if it is made required then it would be a problem. Without making it required can we do it using behaviours please suggest.
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.