Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How Hide/Show Cascading Field Value?

Shah Baloch April 6, 2022

Hi community, how can I hide the second part of Cascading custom field? I would like to hide the second part base on the selected value of the first part.

For example, I have a field "Dept" and it contains names of all departments.

  • Customer Service
  • Human Resource
  • Sales
  • Technology
    • Database
    • Development
    • Support
  •  Quality Assurance   

I would like to hide the sub-value part of the field. Once the user selects Technology then it should show the second sub-value part (Database, Development, Support). I tried the below behaviour script but it didn't work. Any idea how can I make it work?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FieldBehaviours


def primaryField = getFieldById("customfield_13200")

def subField = getFieldById("customfield_13200:1") //not sure sub value part can be define like this

if (primaryField.value == "Technology") {

subField.setHidden(false) }

else {

subField.setHidden(true)
}

Thank you for your help.

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2022

Hi @Shah Baloch ,

unfortunately you can't hide just the second part of your cascading select list.

Your code is incorrect!

def subField = getFieldById("customfield_13200:1") //not sure sub value part ca

In order to take value of second part of your field :

def subField = primaryField.getValue().get("1")

You can change or set that second part value but you can't hide just the second part.

My suggestion is to set a None value for all values in second part where there are no values.

Hope this helps,

Fabio

TAGS
AUG Leaders

Atlassian Community Events