I'm using the following script in Scriptrunner Behaviors and it's almost working:
(The Field this is triggered off of is a field named "Products", and here is the script)
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def ProductsField = getFieldById(getFieldChanged())
def otherProductField = getFieldByName("Products (Other)")
def selectedOption = ProductsField.getValue() as String
def isOtherSelected = selectedOption == "Other"
otherProductField.setRequired(false)
otherProductField.setHidden(true)
if (isOtherSelected)
{
otherProductField.setRequired(true)
otherProductField.setHidden(false)
}
The above is supposed to HIDE a field named "Products (Other)" and initially set it as (required = false) and hidden = true
That works, but when I select "Other" in the "Products" field, the opposite is supposed to execute. That is, the custom field "Products (Other)" should be unhidden and required.
When I select "Other" in the "Products" field and nothing happens until I click the "Create" button for the issue, THEN the "Products (Other)" field becomes unhidden as desired, but it's STILL NOT "required". What's wrong with my code?
(Using Jira 8.13.6, the "Input version" field on this submission form doesn't want me to type in it).