I have an "Affects Branch/es" custom field, and I'd like to force to have only one of "Affects version/s" and "Affects Branch/es" filled - in our system filling none or both is invalid.
A tried the following code, but it does not work:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def branchesField = getFieldByName("Affects Branch/es")
def branchesFieldStringValue = branchesField.getValue()
def versionsField = getFieldById("versions")
def versionsFieldStringValue = versionsField.getValue()
if (branchesFieldStringValue == null && versionsFieldStringValue == null) {
branchesField.setError("brancherror both empty 3")
}
if (branchesFieldStringValue != null && versionsFieldStringValue != null) {
branchesField.setError("brancherror both filled 4")
}
I think the problem is the way I checked if they're empty or not. I tried with converting them with .tostring() and comparing with "" and some other ways - but now I think I'm getting lost. Can someone help me?