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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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

Atlassian Community Events