ScripRunner question: How to restrict drop down list based on Issue Type

Agatha Nicodin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 7, 2023

Hey everyone,

To say I'm a newbie with ScriptRunner would be an understatement. I needed to find a way to limit the values shown in a drop-down list based on the issue type. I've then managed to find that you're only able to do so via script runner. And here I am. 

I've managed to install script runner, find my team-managed project custom field ID, and ran some scripts I found online. As I'm sure this is not a novel request, I'm curious if you know/have a script I can run or if you can spot any issue in the script I'm trying to run-- it's been giving me the below error when I do.

org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: Script1.getFieldById() is applicable for argument types: (String) values: [customfield_12128] at Source)

Caused by: groovy.lang.MissingMethodException: No signature of method: Script1.getFieldById() is applicable for argument types: (String) values: [customfield_12128] at at Script1$ Source) at Script1$ Source) at at at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at Source) at at at$0(MainHandler.groovy) at$_handleRequest_closure1.doCall(MainHandler.groovy:171) at$


And this is the code I'm running (copied from:

int selectListId = 12128
def selectList = getFieldById("customfield_" + selectListId)

String issuetype = getIssueContext().getIssueType().getName()
def map

switch (issuetype) {
case "Production":
map = ["Defect", "RFS", "RFI"]

case "Change Request":
map = ["CR", "Additional Requirement", "Sub-task"]

case "Defect":
map = ["Pre-UAT defect","UAT defect", "SIT defect"]

if (map) {


 Of course, I'll populate my script with relevant details to our org (field id has been correctly adapted) however, I want to see if it passes in the first place. 


Any ideas are appreciated!

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2023

Hi @Agatha Nicodin

To answer your question, this is doable. However, the approach you are currently using will not work on Jira Cloud. It is only applicable to Jira Server / DC.

For Cloud, you must make multiple Behaviour configurations if you intend to filter the Select List according to the Issue Type.

Firstly, you will need to gather some information, i.e. the custom field's id, which you appear to have acquired and next, the ids for the custom field values.

1. Edit the Options for the List you intend to filter

2. Move your mouse over the Edit link. You can view the Option's ID as shown in the browser footer in the screenshot below.


You will need to use the information above to filter the option for the select list.

Next, create a Behaviour configuration and set it for a specific issue type.

In the screenshot below, the Behaviour is configured for the Task issue type.


Next, add the script below to the Behaviour configuration:-

getFieldById("customfield_10118").setOptionsVisibility(["10178", "10179"], true)

Below is a screenshot of the Behaviour configuration:-


So the custom field id used in the code above is for the single-select list. In this example, the field I'm using is called Sample List, and the values 10178 and 10179 and the IDs for the options, Option 1 and Option 2 from the Sample List.

Since you intend to add this filter for multiple Issue Types, you must create separate Behaviour configurations for each issue type.

Below is a test screen of the filtered list option when the Task issue type is selected:-


I have created a similar configuration for the Bug issue type and changed the options to Option 3 and Option 4. Below is a screenshot for your reference:-


And for all other Issue Types where the filter is not added, all the options will be displayed as shown in the screenshots below:-



I hope this helps to solve your question. :-)

Thank you and Kind regards,


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events