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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.