Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Setting up a scriptrunner behavior and need to add "Unknown" to a filtered version list

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?

1 answer

1 accepted

1 vote
Answer accepted

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( as Long, }

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events