Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Making a custom field required when another custom field radio button is checked

I would like for when i check the radio button with a value "Yes", and the other custom field to be mandatory. I did this as a behaviour in scriptrunner but it does not seem to work at creation.

Here is my code:

def customA= getFieldById("customfield_16191") // regular select custom field
def customB= getFieldById("customfield_14200") //radio button
//def customB_val= customB.getValue() as String

if (customB_vall == "Yes"){
customA.setRequired(true)
}

 

Would anyone have any idea what i'm doing wrong as i can't figure it out. Or perhaps this functionality is not possible on the create issue screen

1 answer

1 accepted

1 vote
Answer accepted

This is absolutely possible.

I see some typos in your script.

Try like this:

def customA= getFieldById("customfield_16191") // regular select custom field
def customB= getFieldById("customfield_14200") //radio button
customA.setRequired(customB.value == "Yes")

Make sure this script is installed on the customB field so that it is executed with each change of value the radio button. 

Ah it should have been:

def customA= getFieldById("customfield_16191") // regular select custom field
def customB= getFieldById("customfield_14200") //radio button
def customB_val= customB.getValue() as String

if (customB_val == "Yes"){
customA.setRequired(true)
}

 

My script works, it was just that I had set it on the select custom field and not the radio button. But I would prefer using the script you provided as it was smoother upon execution. I could select and de-select the radio button as many times and it would be required or not required accordingly. Thanks for the help!

Suggest an answer

Log in or Sign up to answer
TAGS

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