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

In Jira how to control the values of a multi select field based on value selected on another field

Ganeshan prakash Apr 04, 2019

I have requirement, request your help here:

I have two custom fields ApplicationName (single select) & Componentname (multi select).  Now based on the value selected in Application field values of Component field should change.

With the help of this post, thanks for this post - https://community.atlassian.com/t5/Marketplace-Apps-questions/Show-Hide-options-from-cascading-select-list/qaq-p/260685

I am able to come up with the below script which works perfectly but I need to select any value in the "Component" field for the changes to reflect.  Is there a way when the Application field is selected and Component field updates automatically without being selecting a value in Component field?

Thanks in advance.

 

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor

def appField = getFieldByName("ApplicationName")
def selectList = getFieldByName("ComponentName")

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

def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

def appselectedOption= appField.getValue() as String

if(appselectedOption.contains("App")){
def optionsMap = options.findAll {
it.value in ["UI", "Web"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap)
}
else if(appselectedOption.contains("DB")){
def optionsMap1 = options.findAll {
it.value in ["Oracle", "SQL"] // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectList.setFieldOptions(optionsMap1)
}

 

0 answers

Suggest an answer

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

Here’s what we’re doing to make Jira Cloud faster

Hello Community 🤗 I’m Nikhil, a Product Manager on the Jira Cloud team working on performance improvements. Performance is an ongoing journey and we continue to invest heavily in it. We under...

11 views 0 2
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