I have a requirement to check that at least one of five date/time custom fields on the screen has a value. If all five are empty, I need to stop the transition until at least one date field has a value. To make things more complicated, if the first field has a value, then the other four fields should be empty. And if any one of the four fields has a value, then the first field must be empty.
So,
if date fields 1-5 are empty, require at least one field AND
if date1 has a value dates 2-5 need to be blank
If any of dates 2-5 has a value, date 1 needs to be blank.
I'm really struggling to just determine if a date/time field has a null value. Using Behaviours, I tried the below checking if reqdateField or reqdateVal was null and that doesn't work. I also tried (!reqdateField) and (!reqdateVal) and that didn't work. Any ideas? If I can figure out how to check for a null value, I can probably come up with figuring out the combinations of fields. This is for Jira Data Center.
def reqdateField = getFieldByName("Requested Release Date/Time")
def reqdateVal = reqdateField.getValue() as String
def p1 = getFieldByName("P1 Release Date/Time")
def p2 = getFieldByName("P2 Release Date/Time")
def p3 = getFieldByName("P3 Release Date/Time")
def p4 = getFieldByName("P4 Release Date/Time")
if (reqdateField == null && p1 == null && p2 == null && p3 == null & p4 == null) {
if (reqdateVal == null ){
reqdateField.setError("Please provide Requested Date or one or more Phased Release dates.")
} else {
reqdateField.clearError()
}
}