Jira Script-runner disablele custom field based on radio value

I have a radio button with value yes, no, two multiline text field A, B. Wonder if I can following:

If radio button value == Yes

A enabled, B will be disabled

If radio button value == No 

A disabled, B will be enabled

 

I am doing this in behavior script

1 answer

1 accepted

This widget could not be displayed.
Jenna Davis Community Champion Aug 28, 2017

You can do something like this:

def radio = getFieldById(getFieldChanged())
def fieldA = getFieldByName("FieldA")
def fieldB = getFieldByName("FieldB")

def selected = radio.getValue() as String

if(selected == null) {
fieldA.setFormValue(null)
fieldA.setHidden(true)
fieldB.setFormValue(null)
fieldB.setHidden(true)
}
if(selected == "A"){
fieldB.setFormValue(null)
fieldB.setHidden(true)
fieldA.setHidden(false)
}
if(selected == "B"){
fieldA.setFormValue(null)
fieldA.setHidden(true)
fieldB.setHidden(false)
}

This will need to be set up on your radio button field. It currently is set up to disable (set hidden and set to null) both fields if 'None' is selected. You can change this by modifying the first 'if' if you'd like. If you need help with this or anything else, let me know. :)

Regards, 

Jenna

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

511 views 3 18
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