How do I display a field based on the values of a Single select list in JIRA?

Hello, I am have been trying to display a field based on the value of a single select list using the example mentioned in the page below, but it doesnt work.

https://confluence.atlassian.com/jirakb/how-to-display-a-field-based-on-another-field-s-selection-649921383.html

I read that it can be achieved using Behaviors in ScriptRunner?

Can I get some more information on how this could be done?

2 answers

This widget could not be displayed.
This widget could not be displayed.
Steven Behnke Community Champion Apr 01, 2016

I wrote my own updated version of that script, I can provide it – 

<script type="text/javascript">
/*---------
   Use Case
-----------
   Only show targetField when the changingField is set to
   desiredValue.
-----------
   This is using basic javascript and the jquery library
   provided by atlassian. This should be within the Field
   Description, within the Field Configuration.
   The jQuery can be accessed using the AJS.$ wrapper.*/
 
    //Obtain the first field by ID
    changingField = document.getElementById('customfield_13322');
     
    //Start our process if the field is present
    if (changingField) {
         
            //Desired value to show the target field
            desiredValue = '10939'
  
            //Obtain the second field by ID
            targetField = document.getElementById('customfield_13708');
  
            // This first if-statement will hide the target field immediately, unless the default value is set to our desired value
            // Hide the target field's container if changing field isn't set the desired value
            if (changingField.value != desiredValue) AJS.$(targetField).parent().hide()
  
            // onchange runs when a select field changes. Basic logic here shows it for desired value, hides it for all else
            // Be sure to set the field to nothing when using the else clause to hide the field container, otherwise you'll still submit data
            changingField.onchange=function() {
                if (this.value == desiredValue) {           
                    AJS.$(targetField).parent().fadeIn( 200, "jswing" )
                    } else {
                        targetField.value='';
                        AJS.$(targetField).parent().fadeOut( 200, "jswing" )
                      }
            }
    }
 </script>
Steven Behnke Community Champion Apr 01, 2016

Unfortunately I haven't done this specific task with ScriptRunner Field Behaviors – You can look for hints or examples on the documentation page: https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_examples

Can you please advise how this can be done using a Cascading Select. I am not too familiar with java script. Might need to get sometime to learn more about JS.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

99 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you