* 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.
Have identical problem and unfortunately no solution.
Any ideas how to fix this?
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.