Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ScriptRunner behaviour for hiding a field based on another fields value


Given the user is trying to create or edit an issue,

When the component (Component/s) is chosen as "Generic_Tasks"

Then the custom field "DoD" (customfield_14201) should be hidden.


This is the simple script I used but it doesn't seem to work:


def ComponentsField = getFieldById("Component/s")
def DoDField = getFieldById("customfield_14201")
def Componentvalue = ComponentsField.getValue()

if (Componentvalue == "Generic_Tasks") {


else {


Any help here is highly appreciated.

Thanks in advance,


1 answer

1 accepted

1 vote
Answer accepted

Hi @venkataramanan_s 

you'll have to place this script as server side script for Component/s field

import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours

def plan_modification = getFieldById('customfield_39257') //replace with Dod field Id

def components = getFieldById(getFieldChanged()).getValue() as List<ProjectComponent>
def compField = getFieldById("component")

if (components.any {"Generic_Tasks")}) {
else {

Hello @Vikrant Yadav ,

Thank you so much for the quick solution.

This one worked like a gem !


Thanks again !



Like Vikrant Yadav likes this

@venkataramanan_s  Cool, Glad to hear it works for you!

Hello @Vikrant Yadav 

In addition to this,

I also need help with another behaviour with the Xray "Test Repository path" field.

WHEN the "Test Repository Path" is "NTG7 Widgets"

THEN the custom fields "Review" and "Review Comments" should be made mandatory.



Thanks in advance,


Hi @venkataramanan_s  Is Test Repository path dropdown field ? 

I think this is a field of a plugin. We can apply behaviour on dropdown field not sure it works on XRay plugin field or not. 

Have you tried to apply Behaviour on this field similar to dropdown field ?

We dont have this plugin in our JIRA instance, so didn't get chance to apply Bheaviour on this field.

If you need a script similar to dropdown field i can share. or you can create new thread in Atlassian Community, might be anyone tested Behvaiour on XRay plugin field.


Vikrant Yadav


Hello @Vikrant Yadav ,


yes, it is a special field part of the Xray plugin. The type of the field is also called "Test Repository Path". I am not sure what category it comes under.



Nevertheless, Could you please share the script for a dropdown field ?

I will see if i can relate that to this.


Thanks a lot for your assistance,



def dropDown = getFieldById("customfield_10500")
def conditionA = getFieldById("customfield_10501")
def conditionB = getFieldById("customfield_10502")
log.debug("dropdown value" + dropDown.getValue())

if (dropDown.getValue() == "a") {
} else {



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

325 views 0 10
Join discussion

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