Forums

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

I have a requirement to show/hide a tab on the basis of an option selected(single select) on the oth

Priyanka khare
Contributor
October 8, 2021

Hello,

 

I have a requirement to show/hide a tab on the basis of an option selected(single select) on the other tab. How can I achieve this?

 

Regards,

Priyanka

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
October 10, 2021

Hi @Priyanka khare

For your requirement, you can use ScriptRunner's Behaviour. 

You will need to configure a Server-Side Behaviour for the Single Select List.

Once you have done so, you will need to include some conditions in the Server-Side Behaviour.

Below is a working sample Server-Side Behaviour code for your reference:-

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours
def list1 = getFieldById(fieldChanged)
def list1Value = list1.value.toString()
showTab(1)

if(list1Value == 'Hide') {
hideTab(1)
}

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

What this code does is that when the Hide option is selected from the list, the second tab, i.e. Tab 2, will be hidden. Else, if any other option is selected, the second tab is made visible once again.

Below is a print screen of the Behaviour configuration for your reference:-

behaviour_config.png

Also, I am including a few test screens for your reference:-

 

If the option selected from the List 1 field is either None or Show, both the tabs will be visible as shown in the first two print screens below:-

test1.png

test2.png

 

If the option selected from List 1 is Hide, the second tab will be hidden as shown in the image below:-

test3.png

 

I hope this helps to solve your question. :)

Thank you and Kind Regards,

Ram

Priyanka khare
Contributor
October 11, 2021

Hello @Ram Kumar Aravindakshan _Adaptavist_ ,

 

I appreciate the detailed answer to my question. Many thanks to you. It worked.

 

Regards,

Priyanka

Suggest an answer

Log in or Sign up to answer