Nunjucks expression to find a value in a list Edited

I'm on Jira Cloud and I'm configuring a conditional post function and I want it to run if the value of a custom field is in a list. 

For example, I have 60 values defined in a custom field called Departments.  If the value of the Department is either U, V, W, X, Y or Z then run the post function. 

I know I could do something like 

{{ issue.fields["Department"].value == "U" or issue.fields["Job Title"].value == "V" or issue.fields["Job Title"].value == "W" or issue.fields["Job Title"].value == "X" or issue.fields["Job Title"].value == "Y" or issue.fields["Job Title"].value == "Z" }}

I wanted to find out if there was a way of doing this without using a bunch of OR clauses. Is there something similar to an IN statement I could use? 

Also, is there a maximum number of post functions I can have on a single transition? 

1 answer

1 accepted

0 vote

Hi Dale, 

Your 'Department' custom field is a single select list, yes? I'm also going to assume that it's ID is '11111'

import com.atlassian.jira.component.ComponentAccessor

def cfDepartment = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11111)
ArrayList valuesToCheck = new ArrayList()
valuesToCheck.addAll("U","V","W","X","Y","Z")
if (valuesToCheck.contains(issue.getCustomFieldValue(cfDepartment).getValue()) == true){
return true
}
return false

Just what I was looking for! Thanks!

Do you know if there is a max number of post functions I can have on a transition? 

Also, I'm looking into some training on this. Any suggestions? 

Ivan Tovbin Community Champion Jan 25, 2018

I'm not aware about any such limitation. From my experience I've had ~10 post functions maximum on a transition.

As for training, I'm afraid I don't have an answer for that one. I'd suggest you start a new Discussion about it here on the Community and see what others have to say.

P.S. Please mark the solution as "Accepted" if it's working for you. 

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 May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

823 views 2 9
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