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

Scriptrunner Behavior to find 'None' value


Hey there,

I'm working on a script that detects the field values and reacts accordingly, but I'm running into an issue where I can't accurately determine if a multi-list selection is equal to the default option, "None". The same is true even after selecting a different item, then clicking back to "None". I am able to get my code to react to the values selected otherwise.

The code is executing under the myVariable field. Any help is greatly appreciated - code below.

def myVariable = getFieldById("customfield_15201")
String myVariableValue = (String) myVariable.getValue()


// I've tried all of the following and none of these work.

if (myVariable.contains('None')) { ... }
if (myVariable.contains(null)) { ... }
if (myVariable.equals('')) { ... }
if (myVariable.equal('None')) { ... }
if (myVariable.equals(null)) { ... }
if (myVariable.isEmpty()) { ... }
if (myVariable.isBlank()) { ... }

1 answer

1 accepted

2 votes
Answer accepted

Your error is with 

String myVariableValue = ( String ) TeleportField .getValue()

In my experience, it's never a good idea to perform this sort of type conversion in groovy.

A multi-select field should typically return an array. If you convert that to strings, it becomes complex to process it.

Let groovy do the work for you.

def myField = getFieldById("customfield_15201")
def myFieldValue = myField.value
//the field is not populated, that could be because it returns one of the followin
if(myFieldValue == null){ "field is null"
if(myFieldValue instanceof String){ "field is an empty string"
if(myfieldValue instanceof List){ "field is an empty array" //this is the only one that should output on a multi-select field

} else {
if(myfieldValue instanceof List){
//bonus, if you have values in your multi-select
myFieldValue.each{selectedOption-> "label of the selected option is: $selectedOption"
//or if you want the optionIds
myfield.formValue.each{optionId-> "id of the selected option is: $optionId"

Thanks, this helped me get to where I wanted to go.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events