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

0 votes
Accepted answer
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 Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,369 views 0 8
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