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

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
Community showcase
Published in Jira

[Survey] Development tools and DevOps - share your thoughts!

Hey Community! I work at Atlassian in product marketing and we are conducting a survey to better understand how people feel about their development tool chain and DevOps. We would love if you could...

119 views 1 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