Scripted Field that changes based on another Checkbox field

Hey all,

I'm trying to make a scripted field that reads another field to determine it's value, like below:

def String multiSelectField = getCustomFieldValue("TestSL")
switch (multiSelectField) {
    case "1":
    return "one@test"
   
    case "2":
    return "two@test"
   
    case "3":
    return "three@test"
   
    default:
        return ""      
}

... but I need to alter it to take checkbox field results instead of a multiselectfield (so that checking 1, 2, or 1 & 2 will return different results).  But I can't find where I pull the checkbox options for making it work.

 

2 answers

1 vote

If TestSL is a multi select it will return a list of Option objects... so

def multiSelectField = getCustomFieldValue("TestSL")*.value 
...
case (["1"]) ...
case (["1", "2"]) ...

Untested... Not sure about the ordering, you may need to cast to a Set to remove any ordering.

Add some logging to see the value of multiSLField...

 

 

Thanks for the answer!  So that's just using a wildcard * to grab the list of values, then run a list of cases to see if it matches any of those values, correct?  I think I understand, but this is my first time using Scripted Fields and I'm afraid I'm not very savvy with the language.  Is there a place I can reference to construct the case functions?  I', trying to following the formatting by I can't get it to work.  Does Scripted Fields use... what is it, Groovy scripts?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

134 views 0 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you