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

Treating the None field in Multilist as a value

Adam Clifford Jun 16, 2018

Hello,

I am trying to write a script that will check if TBC is selected in a multilist selection on JIRA custom field but will let all other fields including None (Default value) Through.

This script allows all values except TBC and None through

def val = cfValues['Testing required Up/Downstream']*.value
if (val.contains("TBC")) {
return false;
} else {
return true;
}

I have tried this script to allow None through but it stops all values

def val = cfValues['Testing required Up/Downstream']*.value
if (val.contains("TBC")) {
return false;
} else if (val == null) {
return true;
} else {
return true;
}

Thanks in advanced for your help. 

2 answers

1 accepted

1 vote
Answer accepted
Nic Brough [Adaptavist] Community Leader Jun 16, 2018

I think your second script is closest to what you need, but it's worth explaining what Jira is doing.  When you look at this field on an issue, there are three possible types of response:

A list of values that includes TBC (return false)

A list of values that does not include TBC (return true)

Nothing, because there are no values selected, although Jira displays "none" in lists or hides the field completely (I think you want to return true here too)

So, I might be a lazy coder and write:

if ( cfValues['Testing required Up/Downstream']*.value )

{

   if ( cfValues['Testing required Up/Downstream']*.value.contains("TBC")

   { return false; }

}

return true;

(That says "if there is a list of values, and one of them is TBC, false, but for other cases, where there is a list without it, or no list at all, return true)

Adam Clifford Jun 17, 2018

Hello,

That was throwing the same error as my script. None was being seen as an error.

Finally got it to work though using the following line

!('TBC' in cfValues['Testing required Up/Downstream']*.value)

Thanks all for your help

Adam

0 votes
Joseph Pitt Community Leader Jun 16, 2018

I believe None is actually null in the database like Unresolved

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

2,690 views 6 15
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