Behaviours plugin filter select list values based on project selection on issue creation

I'm using the behaviors plugin.  I have figured out how to filter the values of a select list.  However, I need to filter this list based on project selection during issue creation.

Script I am using:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def formField = getFieldByName("Location - NA") 
def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionsMap = options.findAll {
    it.value in ["Kansas City", "Bejing", "Memphis"] 
}.collectEntries {
        (it.optionId.toString()) : it.value

2 answers

This widget could not be displayed.

I would switch on:


which should give you a Project... IIRC initialisers fire when the project changes, so that might be a good place to put it. Mikey's answer should work too I think.

This widget could not be displayed.

Generally speaking, I would use your behaviour on the Project field if that is the controlling factor.

  • Go to Your Behavior -> Fields -> Add -> "Project"
  • For the Project field listing, "Add serverside script"

You should then be able to get the value of the project using something like:

projectValue = getFieldById(getFieldChanged()).getValue

Note that I have not actually tested that code.

Once you have the project value you can use if/else statements or a switch statement to set the appropriate field options for the corresponding projects.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

226 views 3 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you