Forums

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

I need to show a field on the basis of another. If click on one of the options on checkbox field the

Priyanka khare
Contributor
October 9, 2020

Hello Community,

I need to show a field on the basis of another. If click on one of the options on checkbox field then the other field(date field) should be visible, if i have not
selected that particular check box then it should be hidden. I am using JIRA server version 8.5.0. How can i achieve this using script runner?

Regards
Priyanka Khare

3 answers

0 votes
Suvarna December 23, 2024

how can we do this kind of behavior without a script runner?

0 votes
Derek Fields _RightStar_
Community Champion
October 9, 2020

You can create a Behaviour in Scriptrunner that will show or hide the field based on the value of the checkbox. Take a look at https://scriptrunner.adaptavist.com/latest/jira/tutorials/behaviours-tutorial.html 

0 votes
Haddon Fisher
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.
October 9, 2020

If you've got ScriptRunner installed, then you can use the 'Behaviors' function to do this pretty easily. Adaptavist has an example in their library on how to do this, but their example is maybe a little more complicated than it needs to be. Here's my example, show\requiring two custom fields if the "Yes" option in the third field is selected. You may need to modify this some with a checkbox field, but this should get you pretty close.

// Get the fields you need
def triggerField = getFieldByName("Custom Checkbox Field")
def showField1 = getFieldByName("Custom Field 1")
def showField2 = getFieldByName("Custom Field 2")

// Evaluate the selected value; in this case, does it equal the string "Yes"

if(triggerField.value == "Yes"){
showField1.setHidden(false)
showField1.setRequired(true)
showField2.setHidden(false)
showField2.setRequired(true)
}

else{
showField1.setHidden(true);
showField1.setRequired(false);
showField2.setHidden(true);
showField2.setRequired(false);
}
Priyanka khare
Contributor
October 16, 2020

Hello @Haddon Fisher 

I need to be able to view the date field even if i select Yes and Na in my checkbox field.

For eg:

I have a checkbox field - Yes, No, NA and i want to-

1.show Date field when Yes is selected(even when yes is selected along with NA)

2. hide the date field if Yes is not selected at all.

Regards

Priyanka

Haddon Fisher
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.
October 16, 2020

Hi @Priyanka khare , in that case you would just need to add a second 'if' clause to show the field if "NA" is selected.

Christina Braun
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 22, 2024

Hi @Haddon Fisher

An old case here but I am trying exactly the same for the create and edit screen.

My case: If in the Checkboxes field "Features" the value "Head-to-Head Test" is selected the Single Issue Picker field "DIGI Ticket" should get visible.

When using the code the "DIGI Ticket" is hidden but it does not get visible when selecting "Head-to-Head Test". Any idea what I'm missing? 

Thanks!
Christina

DIGI ticket.png

Suggest an answer

Log in or Sign up to answer