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

dynamic display a single select list base on issue type

Hi there,

We have a single select list named "service category", which has many options. And I hope it can be dynamic displayed base on issue type value when user submit or edit issues.

For example, when user submit case and choose issue type A, the "service category" field only show A,B and C options. But when user choose issue type B, the field will show other options D and E. I hope it can also work when user edit issue type and "service category" field in a existed issue.

I know it can be done by Behaviours, but I'm a script newbie, could someone tell me how to write the script?

Thank you very much!

2 answers

1 accepted

1 vote
Answer accepted
Antoine Berry Community Leader May 09, 2019

Hi @ClaireYang ,

Please create a behaviours and map it to the "Issue Type" field. Then please try to use this script : 

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

int selectListId = 11001

def selectList = getFieldById("customfield_" + selectListId)
String issuetype = getIssueContext().getIssueType().getName()
def map

switch (issuetype){
case "Incident":
map = ["Value 1", "Value 2"]
case "Task":
map = ["Value 3", "Value 4"]
default :

if (map != null){
def optionsManager = ComponentAccessor.getOptionsManager()
def selectListCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(selectListId)
def fieldConfig = selectListCustomField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(fieldConfig)
def optionsMap = options.findAll {
it.value in map // list of options you want to show
}.collectEntries {
(it.optionId.toString()) : it.value

Update the id of the select list custom field, the values of the issue types the select list values.


Thank you Antonie!!!!! It works perfectly!

Like Antoine Berry likes this

So now how would you do this in a JIRA Cloud instance?

Hello @Antoine Berry  and @ClaireYang ,

I tried the same script. But I am getting an error in the last line.

setFieldOptions method is not working. Error:

Cannot Find Matching method.

groovy.lang.MissingMethodException : No signature of method :

com.atlassian.jira.issue.fields.ImmutableCustomField.setFieldOptions() is applicable for argument types: (java.util.LinkedHashMap) values: [[:]]

Could you please help

Thanks and Regards,

Swapnil Srivastav

Antoine Berry Community Leader Nov 04, 2019


If you follow the logic of the script, the optionsMap being empty either means that : 

  • the issuetype is not in the first switch list
  • the values defined in the "map" are not valid for the select custom field (remember that it is case sensitive)


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

466 views 5 18
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