Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding the Unknown option to a version select custom field

Edwin Ruiz
Contributor
May 16, 2019

* all of this code is added in behaviours 

So i have a custom field of type Version Picker (single version). I want it to only allow unreleased versions to be selected

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.version.Version

def versionManager = ComponentAccessor.getVersionManager()

def versions = versionManager.getVersionsUnreleased(10203, false)
targetVersionField.setFieldOptions(versions)

The above works where it allows users to select only unreleased versions. The only problem is that the field is in the edit screen of a ticket so when they edit a ticket the first option in the list gets automatically selected since there isn't the unknown, none option. 

 

I tried the bottom code but that just doesn't work. It's because None is just a string and the field doesn't allow options of type string but rather of type Version. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.version.Version

def versionManager = ComponentAccessor.getVersionManager()

def vers = ['None']
def versions = versionManager.getVersionsUnreleased(10203, false)
for (Version element : versions) {
log.warn(element)
vers.add(element.getName())
}
log.warn(vers)
targetVersionField.setFieldOptions(vers)
log.warn(vers)

If someone has done this, is this the way to go or should i go a different route? I was thinking I can get the field values and filter from there. 

1 answer

0 votes
Serhii Kremeznyi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 11, 2020

Have identical problem and unfortunately no solution.

 

Any ideas how to fix this?

Suggest an answer

Log in or Sign up to answer