Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script to Show/Hide Custom Text Field Based on Field with Checkboxes not working completely Edited

Hi Everyone,

I am using this code in order to show a textField based on checking the value of Other in my checkbox field.  However, I want to be able to select any of the checkboxes in my formField and show the textField.  I have tried to place || between each value in the 'if' statement, but I cannot get multiple values to show/require the textField.  It only shows when 'Other' is checked.  I would like to show/require the textField if any of the checkboxes are checked. 

I have tried this, but it doesn't work:

if (FormFieldValue == "On unit" || FormFieldValue == "Other, Please specify:")

Thank you for any help!!!



def FormField2 = getFieldById("customfield_15754")
def FormField = getFieldById("customfield_15833")

def FormFieldValue = FormField.getValue()

if (FormFieldValue == "Other, Please specify:") {
} else {

1 answer

Hi Lesley

When you use the behaviours method "FormField.getValue()" on a Checkbox field it changes the data type of the returned value depending on the number of checkbox options selected.

1 checkbox ticked = String
2 or more = List of Strings

So you just need to make sure you handle the data types correctly.

A few people have had issues with this so I wrote an example to show how you can code this in behaviours.

I will get this added to our Script library soon but for now, you can access the example here.


The important part of the code relevant to your problem is:

List<String> chosenValuesList = []
if (checkBoxFieldValue instanceof String) {
} else if (checkBoxFieldValue instanceof ArrayList) {




Thanks, Matthew!

Your script works great for making sure only ‘None’ can be selected, if it is selected!  However, I still want to be able to select the value, “Other,” (which is one of the available options) and have a text box open up for the user to add more information if necessary.  Can I use the following code to show/hide this other field as part of this script, too?  If “Other” (or any value but 'None') is selected, then the user should always see the text box.  Is that possible?  Thank you again!


def textField = getFieldById("customfield_15752")

def FormField = getFieldById("customfield_15821")


def FormFieldValue = FormField.getValue()


if (FormFieldValue == "Other") {



} else {




If you only want to hide the other field if the user chooses "None" from the checkbox and do not care if they also choose another value as well as "None" then you can use this shorter example here.




Hi Matthew,


I apologize for the delay.  I tried your code, then, I tweaked it a bit to get the results that I am trying to achieve (note the 'Other' in the second to last paragraph).  However, I am still having this problem - is there any way around it?  Thanks!



If the 'Other' checkbox is selected, then de-selected, it still requires the user to type in the Text Box and leaves the text in the Text Box.

I would prefer - if 'Other' is de-selected, then the Text Box should clear and no longer be required and be hidden again.


import com.onresolve.jira.groovy.user.FieldBehaviours
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours
def log = Logger.getLogger(getClass())

def otherField = getFieldById("customfield_15752")
def checkBoxField = getFieldById(getFieldChanged())
def checkBoxFieldValue = checkBoxField.getValue()


checkbox field value = $checkBoxFieldValue
checkBoxFieldType = ${checkBoxFieldValue.getClass()}


List<String> chosenValuesList = []
if (checkBoxFieldValue instanceof String) {
} else if (checkBoxFieldValue instanceof ArrayList) {

//if the user has None selected and nothing else:
if("Not applicable" in chosenValuesList && chosenValuesList.size() == 1){

//if the user has selected None and attempts to select another value:
}else if("Not applicable" in chosenValuesList && chosenValuesList.size() > 1){
checkBoxField.setError("You can't select another value if \"Not applicable\" is selected.")

//if the user has NOT selected None and the list size is greater than or equal to 1
}else if ("Other" in chosenValuesList && chosenValuesList.size() >= 1) {

//if the user has no value selected at all in the checklist field force them to populate the otherField.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

New cloud apps roundup - June 2021

Since our last roundup in April, Atlassian's Marketplace Partners have added over 100 new cloud apps to the Atlassian Marketplace to help your teams work more efficiently. Let’s take a quick look a...

378 views 5 12
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you