Click a check box and display other fields within the screen Edited

Hi everyone,

Using the behaviours initializer on Scriptrunner, I am trying to display certain fields only when a user clicks on a certain check box. I am not sure how exactly to start the groovy script and I am wondering if anybody has seen something similar or has done something similar that they are willing to share. 


Example: User clicks on single day check box and then full day and half day check boxes display along with a date picker. 

1 answer

1 accepted

1 vote
Answer accepted


You should be able to use something similar to what is shown in this example in the docs.

Let me know if you need help getting it set up.



Thanks for the reply Jenna. The field doesn't change when the custom field either gets chosen or clicked. I also used another field besides a checkbox to see if that would work. Some pictures and code can be seen below:Screenshot (145).pngScreenshot (146).png

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor

FormField ParentField = getFieldById(getFieldChanged())   
FormField ChildField1 = getFieldByName ("Day Duration")
String ParentFieldVal = (String) ParentField.getValue()
if (ParentFieldVal == ("Single Day")) {
else {


You should make an initializer function containing this:

def hiddenField = getFieldByName("the field you want initially hidden")

And a behavior function that acts on the check box field containing something similar to this: 

def hiddenField = getFieldByName("the initially hidden field")
def checkBox = getFieldById(getFieldChanged())

def selectedOption = checkBox.getValue() as String
def isOtherSelected = selectedOption == "the checked option(s) that makes your field appear"


You may have to fiddle with with what selectionOption ends up equaling to make it true if you want to use more than one check box in order to make the field appear. I tested this using just one checkbox. This should get you started at least though. 

Let me know if you have any more questions!


Like 1 person likes this

I am sorry, I don't understand the differences between the initializer function and the behanviour function. I am new to working with Behaviour functions.

No problem!

You'll want to create all of this under a single 'Behavior'. However, you want to set up the first part under an initialiser function. 

It will look something like this:

Screen Shot 2017-07-05 at 3.57.36 PM.png

Click 'Create Initialiser' and insert the snippet I provided. 

Then, the field behavior is set up by picking your field (the check box) out of this list:

Screen Shot 2017-07-05 at 3.57.53 PM.pngYou will then see something like this appear:

Screen Shot 2017-07-05 at 3.58.12 PM.pngClick 'Add serverside script' here and add the next part of the code.

When you're done, the entire Behavior should look something like this:

Screen Shot 2017-07-05 at 3.56.13 PM.pngLet me know if you need any more help!



Like 1 person likes this

Hey Jenna, this has been really helpfull. I got it to work.

I have one more question, would this method be able to display a scripted field as a view only in the create window? (Kind of like a dynamic field)

Good! I'm glad I could help you out. :)

Scripted Fields don't show up in the create or update/edit screens.

By a 'dynamic field' do you mean that if you do something in one field the content changes in your read-only field? If so, that would probably be best achieved by another behavior. Just make sure you don't have mutiple behavior functions acting on one field. That can cause unpredictable behavior or make them simply not work. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


263 views 0 6
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