Forums

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

Show/Hide Custom Fields Based on Select List Field Options Using Scriptrunner in Jira Cloud

Digvijay Singh Gehlot
Contributor
September 4, 2025

Hi Community,

I want to show/hide multiple custom fields (text type, checkbox, select list (single/ multiple choices)) based on Select List (single choices) field's values on Issue View screen using Scriptrunner Cloud Behavior in Jira cloud.

Please provide a sample code of "changedField" logic when running On Change and On Load. It will a great help.

Thanks

3 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
September 11, 2025

Hi @Digvijay Singh Gehlot

When using ScriptRunner's Behaviour on Jira Cloud, you need to understand that you cannot code this in Groovy, as the Syntax that is accepted is TypeScript.

For your first requirement of showing/hiding fields, you must do something like this:-

const changedField = getChangeField()

const singleText = getFieldById('customfield_12936')

singleText.setVisible(true)

if (changedField.getName() == 'Single Select List') {

if (changedField.getValue().value == 'Pink') {

singleText.setVisible(false)

}

}

Please note that the sample code above is not 100% exact to your environment. Hence, you must make the required modification.

Firstly, similar to ScriptRunner for Jira DC, since this behaviour depends on the value of a field, you must use the changedField method to initialise the field that will trigger the Behaviour, i.e. getChangeField().

Next, you must add a condition to identify which field has triggered the changed using the first if condition shown in the code above. Unlike in DC, in Cloud, the getChangedField can be used for more than one field.

Also, unlike in Jira Server / DC, you cannot search for a custom field by name. You must search for it using its custom field ID as shown in the example code above.

Below is a screenshot of the Behaviour configuration:-

behaviour_config.png

I suggest going through the Script Runner for Jira Cloud Documentation to understand the concept of the Behaviour.

Below are a few test screenshots:-

1. When the issue dialog first appears for the Create screen all the fields are visible as shown in the screenshot below:-

test1.png

2. If the Single Select List option is updated to Pink, as expected, the Single Text field is hidden as shown in the screenshot below:-

test2.png

3. If any other option aside from Pink is selected from the Single Select List, as expected, the Single Text field is visible as shown in the screenshot below:-

test3.png

I hope this helps answer your question. :)

I am looking forward to your feedback.

Thank you and Kind regards,
Ram

 

Digvijay Singh Gehlot
Contributor
September 13, 2025

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

As always, thank you so much for your message and solution provided. I'll follow the same.

2 votes
Trudy Claspill
Community Champion
September 4, 2025

Hello @Digvijay Singh Gehlot 

I think this YouTube video from Adaptavist has what you seek.

https://www.youtube.com/watch?v=9MNsjBm9New

 

0 votes
Vitalii Rybka
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.
September 4, 2025

In Jira Cloud Scriptrunner, Behaviors are limited vs Server/DC you can’t fully hide/show fields, only set them required/optional or read-only; for onChange you can check the select value and then use setHidden(true/false) in code, but since it’s not fully supported in Cloud, the workaround is using Forms, Forge apps, or making fields read-only/required instead.

Trudy Claspill
Community Champion
September 5, 2025

@Vitalii Rybka 

On what are you basing your statement that using the setHidden() option is not fully supported in Cloud?

I'm not seeing any caveats listed for this functionality in the Issue Details View other than a few fields not being supported.

https://docs.adaptavist.com/sr4jc/latest/features/behaviours/behaviours-supported-fields-and-products#issue-view-supported-fields

Like Digvijay Singh Gehlot likes this

Suggest an answer

Log in or Sign up to answer