Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

What script can I use to restrict the values on a cascade select field?

I have a Cascade Select custom field with the id "19000" and want to restrict the visible values depending on the issue type selected. 

I cannot figure out which script to use... any help would be appreciated 

1 answer

1 vote

This should be a good place to start:

Of course, this is for basing one single select on another, not adjusting the list in a cascading select. But it's virtually the same.

Here is a sample script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
def optionsManager = ComponentAccessor.optionsManager

def csFieldName = 'Root Cause'
def csFieldId = 'customfield_19000'
def csFormField = getFieldByName(csFieldName) // or getFieldById(csFieldId)

def issueType =
def issueTypeOptionMap = [
IssueType1:['Option1', 'Option2'],
IssueType2:['Option3', 'Option4']

def allowedOptionsValues = issueTypeOptionMap[issueType]
def csCf = ComponentAccessor.customFieldManager.getCustomFieldObject(csFormField.fieldId)
def config = csCf.getRelevantConfig(issueContext)
def options = optionsManager.getOptions(config)

Map allowedOptions = options.findAll{it.value in allowedOptionsValues}.inject(["":'None']){ Map map, Option opt->
map[opt.optionId as String] = opt.value
} else {
csFormField.setHelpText("No valid options for this issue type:$issueType")

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

453 views 2 6
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