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

display transition only if multiple values are selected in a custom field via script runner

Melissa Vega Feb 18, 2016

Hi,

I would like to set a custom condition script to display a transition. as soon as multiple values are selected in 2 custom checkboxes fields, the transition should display. If only one value is selected in each field, the transition should not display.

Thanks for our help

I tried this script :

import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.customfields.manager.OptionsManager import com.atlassian.jira.issue.fields.config.FieldConfig import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.ComponentManager

def activitiesValue = issue.getCustomFieldValue(ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10580")) def entitiesValue = issue.getCustomFieldValue(ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10581"))

def activities_value = "" def entities_value = ""

if (activitiesValue != null){ if (activitiesValue.size() == 2 || activitiesValue.size() == 3 || activitiesValue.size() == 4)     return true } return false

2 answers

1 accepted

2 votes
Answer accepted
Kristian Walker Community Leader Feb 18, 2016

Hi Mel,

This requirement can be achieved by adding a Simple Script condition onto the Workflow which checks 2 check-boxes and says that both check-boxes must have more than 1 value in order for it to display the transition.

I have attached some sample code below where I have configured this on a sample workflow by placing it on the In Progress transition in my JIRA 6.4.12 instance running Script Runner 4.1.3.8.

Code:

cfValues['DemoChecbox']*.find().size() >1 && cfValues['DemoCheckBox2']*.find().size() >1

Config:

image2016-2-19 8:32:15.png

image2016-2-19 8:32:55.png

image2016-2-19 8:35:16.png

I hope this helps.

Thanks

Kristian

0 votes
Melissa Vega Feb 19, 2016

Hi Kristian it's perfect smile smile thank you so much

you saved me!

Kristian Walker Community Leader Feb 19, 2016

Hi Mel,

I was glad that I was able to help.

Kristian

Suggest an answer

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

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

741 views 7 0
Join discussion

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