Forums

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

Show/ Hide Custom Fields based on Checkbox options using Scriptrunner Cloud Behavior in Jira Cloud

Digvijay Singh Gehlot
Contributor
August 20, 2025

Hi Community,

I want to show/ hide 3 custom fields (Text type, Select List (single choice) type, and checkbox type) based on another Checkbox field options on Issue View screen - using Scriptrunner cloud behavior - in Jira Cloud.

Please provide a sample code of Scriptrunner behavior on how to achieve the above on Issue View screen - it would be a great help for reference.

Thanks

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Champion
August 21, 2025

Hi Digvijay,

I can confirm that behaviours for Jira cloud supports making fields hiding and showing fields based on another value. 

We have an example script located here which shows how to do this and this could be modified to achieve your use case.

I hope this information helps.

Regards,

Kristian

Digvijay Singh Gehlot
Contributor
August 21, 2025

Hi @Kristian Walker _Adaptavist_ 

Thank you for your message.

Could you also provide a sample code on how to hide/show custom fields based on a Checkbox field options using Scriptrunner behavior on Jira Cloud - View screen?

Kristian Walker _Adaptavist_
Community Champion
August 22, 2025

Hi Digvijay, 

I have created a small example here that runs on the Issue View and the On Change event. It hides values when a certain value is selected in a checkbox field and makes them visible when a different value is selected. 

You can use this as a guide to help create the script that you require. 

I hope this information helps.

Regards,

Kristian

Digvijay Singh Gehlot
Contributor
August 27, 2025

Hi @Kristian Walker _Adaptavist_ 

Thank you so much for sharing the sample code, it helped.

I refined the code as per my requirement, where I need to clear the filled values of custom fields when a checkbox is unselected.

I am facing error pop-up message on Issue View screen when script is loading on the page as below:

"There was an error with applying UI modifications. We encountered an error while applying changes made by UI modifications apps"

Could you please review the code as below:

const checkboxFieldName = "Demo Checkbox Field";

const selectField = getFieldById("customfield_10047");
const textField = getFieldById("customfield_10048");
const checkboxField2 = getFieldById("customfield_10049");
const changedField = getChangeField() if (changedField.getName() === checkboxFieldName && changedField.getValue().some(item => item.value === "A")) { // Change "A" here to the value in your Checkbox Field that must be selected selectField.setVisible(true);
textField.setVisible(true);
checkboxtField2.setVisible(true); } else { selectField.setVisible(false);
selectField.setValue(null);
textField.setVisible(false);
textField.setValue(null);
checkboxField.setVisible(false);
checkboxField2.setValue(null); }

 It seems passing (null) in else condition is causing this issue however it is not giving any errors within the behavior > Edit Field Script dialogue.

I also referred to this Cloud Behaviours API doc but not helpful regarding clearing the field's values.: https://docs.adaptavist.com/sr4jc/latest/features/behaviours/behaviours-api

Could you also guide me on how to show/ hide multiple custom fields based on multiple checkboxes?

For example:

Case 1) If checkbox1 is unselected > checkbox2 & checkbox3 are hidden

Case 2) if checkbox1 is selected > checkbox2 is Visible but checkbox3 is Hidden

Case 3) if checkbox1 is selected > checkbox2 is selected > checkbox3 is Visible

Case 4) if checkbox1 is selected > checkbox2 is unselected - checkbox3 will be hidden and the field value gets clear/null.

Case 5) if checkbox1 is unselected while checkbox2 & checkbox3 have values selected, both the following fields will be Hidden and their values will be cleared.

It would be great if you can provide a sample code on how multiple checkboxes are visible/hidden based on multiple checkboxes in a sequence and their values get cleared out when they are unselected.

Looking forward to you message and thanks in advance! 

Kristian Walker _Adaptavist_
Community Champion
August 29, 2025

Hi Digvijay,

Could you please raise a support request here and the ScriptRunner support team will be able to investigate and debug these errors for you.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer