Show fields upon other field selection

UDAYARANGA MUDIGERE February 23, 2016

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

0 votes
UDAYARANGA MUDIGERE February 28, 2016

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?

0 votes
UDAYARANGA MUDIGERE February 24, 2016

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

 

Udaya

0 votes
UDAYARANGA MUDIGERE February 24, 2016

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 

0 votes
UDAYARANGA MUDIGERE February 24, 2016

We are using 3.1.4 version of Script Runner

 

0 votes
UDAYARANGA MUDIGERE February 24, 2016

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

 

 

 

 

 

0 votes
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2016

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events