Forums

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

Hide/Show Fields based on multi select custom field value

PLaksh11
Contributor
July 4, 2025

Hello Community,

We have multi select custom field, where user can select up to 6 values. But whenever user selects 1 value then corresponding 3 custom fields will be visible. If user selects 3 values then 9 custom fields will be visible. So max user can select 6 values and 18 corresponding custom fields will be visible. If user didn't select any value then all the custom fields should be hidden.

Ex: Multi select custom field value: User selects 'A' and 'B'

corresponding Custom field A1, Custom field A2, Custom field A3, Custom field B1, Custom field B2 and Custom field B3 should be visible.

And remaining corresponding custom fields should be hidden.

We have achieved this for single selection using script runner behavior, But when it comes to multi selection how to reduce the code complexity to achieve this using simple code.

Note: It will be helpful if you give the working code.(Jira cloud)

 

2 answers

0 votes
Olha Yevdokymova_SaaSJet
Atlassian Partner
July 4, 2025

Hi @PLaksh11 !

If you're open to alternatives beyond ScriptRunner, one way to simplify this (and avoid complex behaviors scripts entirely) is by using Smart Forms for Jira – an app developed by my team. It’s available for Jira Cloud and lets you:

✅ Use multi-select fields with conditional logic, so you can show or hide sets of fields based on selected options – without coding.
✅ Automatically group related fields (like A1–A3 for "A", B1–B3 for "B") and make them appear only when relevant.
✅ Add this form directly to Jira issues or trigger issue creation – with form inputs mapped to issue fields if needed.

So instead of writing and maintaining a script for every combination, you can configure everything visually with simple “When X is selected → show Y” logic.

Let me know if you’d like a quick walkthrough or a demo form example – happy to help! 👇

0 votes
Gor Greyan
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 Leaders.
July 4, 2025

Hi @PLaksh11

Please try the following code, I am not sure it will work or not, but you can try.

// Define field names mapping
def mapping = [
'A': ['A1', 'A2', 'A3'],
'B': ['B1', 'B2', 'B3'],
'C': ['C1', 'C2', 'C3'],
'D': ['D1', 'D2', 'D3'],
'E': ['E1', 'E2', 'E3'],
'F': ['F1', 'F2', 'F3']
]

// Reference the multi-select field
def selectField = getFieldByName("SelectField")
def selectedValues = selectField.getValue() as List<String>

// Flatten all mapped fields
def allDependentFields = mapping.values().flatten().unique()

// Determine which fields to show
def fieldsToShow = selectedValues.collectMany { mapping[it] ?: [] }

// Hide all, then show only necessary ones
allDependentFields.each { fieldName ->
def field = getFieldByName(fieldName)
if (fieldName in fieldsToShow) {
field.setHidden(false)
} else {
field.setHidden(true)
}
}

Also, you can check the Dynamic Forms add-on from the Marketplace.
https://marketplace.atlassian.com/apps/1210820/dynamic-forms-for-jira?hosting=cloud&tab=overview


Suggest an answer

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

Atlassian Community Events