Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

0 votes
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
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

121 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you