Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Show/hide custom field options based on other custom field options

Maruthi Prasad Syave
December 28, 2025

I have two custom fields both are select list,
one is multi select list and another is single select list.

Multi select list field options are "A" and "B".
Single select list field options are "1","2","3","4","5","6".

Now my requirement is in multi select field if i select "A" i want these option from single select "1","2","3" have to visible to select.
same for 
in multi select field if i select "B" i want these option from single select "4","5","6" have to visible to select.

if i select both "A" and "B" i want all 6 options have to visible 

for your reference i attached screen shot below 

How can i achieve this using script runner behaviours?


Screenshot 2025-12-26 162210.pngScreenshot 2025-12-26 162230.png

3 answers

2 accepted

1 vote
Answer accepted
Maruthi Prasad Syave
December 29, 2025

Thank you @David Freitez  for your information 
this is the script which is working fine for this requirement

// FIELD CONFIGURATION
const DRIVER_MULTI = "customfield_10550";
const TARGET_SINGLE = "customfield_10551";

// MAPPING: Driver Option ID -> Allowed Target Option IDs
// explicit type annotation to help inference
const MAP: Record<string, string[]> = {
    "10133": ["10135", "10136", "10137"],
    "10134": ["10138", "10139", "10140"]
};

// Precompute unique target IDs once
const ALL_TARGET_IDS = Array.from(new Set(Object.values(MAP).flat()));

const driver = getFieldById(DRIVER_MULTI);
const target = getFieldById(TARGET_SINGLE);

// 1. Get Selected IDs Safely
const driverValue = driver.getValue();
// Ensure we map to string[]
const selectedIds: string[] = driverValue ? driverValue.map((opt: any) => opt.id) : [];

// Short-circuit when nothing is selected
if (selectedIds.length === 0) {
    if (ALL_TARGET_IDS.length > 0) target.setOptionsVisibility(ALL_TARGET_IDS, false);
    const currentTargetEmpty = target.getValue();
    if (currentTargetEmpty) target.setValue(null);
}

// 2. Calculate All Options & Allowed Options
const allowedIds = new Set<string>(selectedIds.flatMap(id => MAP[id] ?? []));

// 3. Update Visibility
const toShow = ALL_TARGET_IDS.filter(id => allowedIds.has(id));
const toHide = ALL_TARGET_IDS.filter(id => !allowedIds.has(id));

// Apply visibility changes
if (toHide.length > 0) target.setOptionsVisibility(toHide, false);
if (toShow.length > 0) target.setOptionsVisibility(toShow, true);

// 4. Cleanup Target Value
const currentTarget = target.getValue();
if (currentTarget && !allowedIds.has(currentTarget.id)) {
    target.setValue(null);
}
0 votes
Answer accepted
David Freitez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
December 29, 2025

Hi @Maruthi Prasad Syave ,

Welcome to the Atlassian community.  Good to know that you are already working with the Scriptrunner plugin which is based on GroovyScript.

There are some pages on their documentation that refer Dinamically hide/show a custom field in cloud (https://www.scriptrunnerhq.com/help/example-scripts/dynamically-hide-or-show-a-field-cloud) but this is refering to the entire field and not an specific option.

I see that there are several inquiries in the community regarding this and they point several solutions:

You would need to review these examples and apply the chosen solution and test it intensively. I also recommend that you raise a support request to Adaptavist so they can also provide some options.

Hopefully this helps you answer your inquiry, if so, please vote for it as the answer to your question.

Kind regards,
David 

0 votes
Kristian Walker _Adaptavist_
Community Champion
December 29, 2025

Hi Maruthi, 

It is possible to achieve your requirement in Jira Cloud using the setOptionsVisibility() method that Behaviours in Jira cloud provides.

We have an example here that shows how to restrict field options when a value is selected in a multi-select list field. We also have an example here which shows how to check if a specific value was selected inside a select list field.

You can use these scripts as a reference guide to help create the script you require. 

If you need further support, you should raise a request with the ScriptRunner support team, who can help create the script you require. 

I hope this helps,

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events