Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

248 views 2 1
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