Can I use a multi select field to conditionally hide fields

Jenifer Kuntz September 28, 2023

This video (Behaviours demo: Conditionally show/hide custom field with ScriptRunner for Jira Cloud) is what I need to do except that the field I am using is a multi select rather than a singe select field.  Can this still be done?

 

https://www.youtube.com/watch?v=-Jt9BIlGcq4

 

Thanks

Jenifer

1 answer

1 accepted

0 votes
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.
October 11, 2023

Hi @Jenifer Kuntz

To answer your question, yes, this is doable.

Below is a sample working code for your reference:-

const changedField = getChangeField()
const multiSelect = getFieldById("customfield_10045")
const textField = getFieldById("customfield_10109")
textField.setVisible(true)

const multipleSelect = getFieldById("customfield_10045")
const myJSON = JSON.stringify(changedField.getValue())

if (myJSON.includes('Apple') ) {
textField.setVisible(false)
}

Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below are the screenshots of the Behaviour configuration:-

behaviour_config2.png

 

behaviour_config.png

So, in this example, when the option Apples is selected from the Multi-Select List, the Multi-Line text field will be hidden.

Below are a couple of test screenshots for your reference:-

1. First, I try to create a new issue. When the issue dialog appears, the Text Field(Multi field) is visible by default.

test1.png

 

2. Next, when I select the option Apple from the Multi-Select List, the Text Field (Multi Line) is hidden as expected, as shown in the screenshot below:-

 

test2.png

 

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

 

Thank you and Kind regards,
Ram

 

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.
October 13, 2023

Hi @Jenifer Kuntz

Has your question been answered?

If yes, please accept the answer provided.

Thank you and Kind regards,

Ram

Jenifer Kuntz October 16, 2023

Thank you Ram, I missed the email.  This is very helpful!

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