Show fields upon other field selection

I have 5 fields. 3 radio button fields and 2 text fields. Initially, only one field should be displayed when Create button is pressed. With the behaviours plugin and the initializer, I was able to hide the other 4 fields.

Now, when I click on the 1st radio button field, the second radio button field should be displayed. How do I achieve it? Could you please help me here?

Thanks

Udaya

6 answers

Hi 

You can 'attach' a behaviour to your radio btn and in the serve rside script use the follow script

def radioBtn = getFieldByName("radio btn")
def description = getFieldByName("Test Hide")

if (radioBtn.getValue() == "Option1") {
    description.setHidden(true)
} else {
    description.setHidden(false)
}

Can I ask you which version of SR you use ? Because the behaviours plugin was merged to SR in a very early version.

Thanos:

Good Morning!!! We are using the last available free version of Script Runner. I do not know the version but I will be able to provide it to you right after I get to work. On my way to work now.

Thanks

Udaya

 

 

 

 

 

We are using 3.1.4 version of Script Runner

 

Looks like there is something I am doing wrong here. This is what I am performing right now:

We are using Script Runner 3.1.4 version on JIRA 6.4.12

I have the following custom fields:

  1. Requester Name (User Picker Field)
  2. Summary (Text Field)
  3. Select a Service Type (Radio Button with options Voice and Data)
  4. Select a Requirement (Radio Button with options Service, Service and Equipment, Equipment)
  5. Select an Action (Radio Button with options New, Change Existing Service, Disconnect)
  6. Purpose (Multi Text Field)

Steps:

  • When the user clicks on the Create button and selects the required project, it should only show Requester Name, Summary and Select a Service Type fields. (I was able to achieve this from the Behaviours plugin)
    • Added a Behaviour named Hide Fields and clicked Add
    • Added a mapping by selecting the Issue Type and Project
    • Clicked on the Fields link and clicked on the Create Initialiser
    • Under Create Initialiser, clicked on the Edit serverside script link and added the following code

 

FormField selectRequirement = getFieldByName("Select a Requirement")
selectRequirement.setHidden(True)
FormField selectAction = getFieldByName("Select an Action")
selectAction.setHidden(True)
FormField enterPurpose = getFieldByName("Purpose")
enterPurpose.setHidden(True)
    •  This allowed me to hide the fields when clicked on the Create button

 

 

 

  • This is where I have the problem. Now I need to display Select a Requirement field when clicking on Select a Service Type radio button options and this is not happening
    • Added another behavior named Show Requirement field and clicked Add
    • Added a mapping by selecting the Issue Type and Project
    • Clicked on the Fields link and selected the Select a Service Type field
    • For this field, I clicked on the Add serverside script and entered the following code

 

def selectServiceType = getFieldByName("Select a Service Type")
def selectRequirement = getFieldByName("select a Requirement")
 
if ((selectServiceType.getValue() == "Voice") || (selectServiceType.getValue() == "Data")) {
	selectRequirement.setHiddent(false)
} else {
	selectRequirement.setHidden(true)
}

 

  • After saving the above, I click on Create button to see the fields hidden as expected and when clicked on Select a Service Type radio button options, nothing happens. I tried to put in the same code on the Select a Requirement field also, but nothing happens.

Could you please let me know what is my issue here? I would appreciate your help in this matter. 

Thanks

Udaya 

I got this to work using Behaviours plugin. It works excellently.

 

Udaya

The fields are displaying correctly now whenever another field is being selected. But when I click on the Create button, nothing is happening. The ticket is not getting created, What might be the issue? Could you please let me know?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

77 views 0 5
Read article

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