Forums

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

Show/ Hide Text fields based on the options selected in Select List (Multi-Choose) field in JIRA DC

Digvijay Singh Gehlot
Contributor
September 2, 2024

Hi Community,

I have created a Select List (Multi-Choose) field with 10 options, and 10 Text fields.

The Text fields should hide/ show based on the selected options present in Select List (Multi-Choose) field.

For example:

  • In Select List (Multi-Choose) field, Option 1 is only selected, then Text Field 1 should only appear.
  • When Option 2 is only selected, and then Text Field 2 should only appear.
  • When Option 1 and Option 2 both are selected, then Text Field 1 and Text Field 2 both should appear.

Please guide with a sample code on how to configure the above use-case by using scriptrunner, jmwe-app, or jira automation if possible?

Thanks

1 answer

0 votes
Muhammad Saqib
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!
September 2, 2024

Yes, you can achieve this using ScriptRunner Behaviours in Jira. Behaviours give you more control over fields in Jira, such as allowing you to dynamically control the visibility of fields based on the selections made in other fields.

Here’s an updated sample script based on your specific use case:

Steps:

1. Go to ScriptRunner > Behaviours.
2. Create a new Behaviour and map it to the appropriate issue type or project.
3. Add the following script to the Behaviour of your Multi-select list field.

 

def myField = getFieldById(getFieldChanged())

List multipleValue = myField.value as List

def textField1 = getFieldByName("Text Field 1")

def textField2 = getFieldByName("Text Field 2")

// Hide all text fields by default

textField1.setHidden(true)

textField2.setHidden(true)

// Show relevant text fields based on selected options

if (multipleValue.contains("Option 1")) {

textField1.setHidden(false)

}

if (multipleValue.contains("Option 2")) {

textField2.setHidden(false)

}

for more info regarding how ScriptRunner behaviours work, here is the documentation 

Suggest an answer

Log in or Sign up to answer