Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Scriptrunner, Substract values from a select list depending on the values chosen on another list

We've been given three custom fields, Batch 1, Batch 2 and Batch 3.

Each one is a multi-select list with the same list of options.

However any option selected on Batch 1 must be substracted from the selection of Batch 2, and any option chosen on Batches 1 and 2 must disappear from the options in Batch 3.


I have managed to make the operation with a Script Behaviour but only with Single Select Lists (which sadly is to little use when you have more than 50 values per list), Multi-select lists only remove the value 'None' in Batches 2 and 3, no matter if the values in Batch 1 change.


Here's the code I have, it works on single select lists but not on multi-select:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def Batch1Field = getFieldByName("Batch 1")
def Batch1Val = Batch1Field.getValue()

def Batch2Field = getFieldByName("Batch 2")
def customFieldB2 = customFieldManager.getCustomFieldObject(Batch2Field.getFieldId())
def configB2 = customFieldB2.getRelevantConfig(getIssueContext())
def optionsB2 = optionsManager.getOptions(configB2)

def optionsMapB2 = optionsB2.findAll {
it.getValue() != Batch1Val
}.collectEntries {
(it.optionId.toString()) : it.value

def Batch2Val = Batch2Field.getValue()
def Batch3Field = getFieldByName("Batch 3")
def customFieldB3 = customFieldManager.getCustomFieldObject(Batch3Field.getFieldId())
def configB3 = customFieldB3.getRelevantConfig(getIssueContext())
def optionsB3 = optionsManager.getOptions(configB3)

def optionsMapB3 = optionsB3.findAll {
it.getValue() != Batch1Val && it.getValue() != Batch2Val
}.collectEntries {
(it.optionId.toString()) : it.value

 Got no idea on how to proceed forward, been stuck at this point looking for a way through for a couple of hours by now... I'd appreciate any ideas dropped by.

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

132 views 1 10
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