You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I have behaviors that filter a project's version list based on the selection of a product custom field. I can populate the list of versions properly, but I want to allow for a blank selection, similar to the "Unknown" option on the non-modified version list. I want to give users the ability to zero out the version field. And I would also like it to be the first option as when I edit an issue that hasn't had that version set, it'll populate it with the first version on the list (not cool).
The versions are in a collection :
Collection<Version> prodVersions = versions.findAll{Version version -> version =~ /^06\.03.*[\d]$|^0[7-8].*[\d]$|^Not.*|^0[6-8].*Patch$|^0[6-8].*Pack$/ }
How do I slap a "None" or blank or Unknown at the top of that Collection?
I figure I'll answer my own question here so I can serve as a warning to others... but to get that blank, 'Unknown' entry, I don't do it directly to a list of versions.... because that 'Unknown' value in the UI is backed up by an entry with an id of -1.. and you can't add an invalid version to a Collection<Version>.
So instead:
Collection<Version> prodVersions = [...]
Map<Long, String> versionFieldOptions = [(-1L): "Unknown"] // This seeds the map and creates that initial, blank entry in the UI
prodVersions?.each { versionFieldOptions.put(it.id as Long, it.name) }
someVersionFormfield.setFieldOptions(versionFieldOptions)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.