I have two code sets of code for the date picker custom field named - Issue close date
one is for future date not allowed and the other one is the that the close date should not be before the issue start date.
" The future date not allowed" feature was working earlier. But when I added one more behavior to show the message "close date should not be before the issue start date" the future date not allowed message is not coming. It is now allowing future dates. Could you look into the issue
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Date.*
def startDateField = getFieldByName("issue Detected Date")
def startDateValue = startDateField.getValue() as Date
def dueDateField = getFieldByName("issue Closed Date")
def dueDateValue = dueDateField.getValue() as Date
def strErrorText = "Closed Date must be greater than Detected Date"
if(startDateValue > dueDateValue){
dueDateField.setError(strErrorText)
}else{
dueDateField.clearError()
}
import com.atlassian.jira.component.ComponentAccessor
import java.util.Date.*
//get the Date Field here
def cfDate = getFieldByName(" issue Closed Date")
def date= cfDate.getValue() as Date
//get today's date
def today = new Date()
// In case today+1 date needs to be checked
//def tomorrow = today.plus(1)
//Check the condition for date less than are equal to today
if(date.after(today)) {
cfDate.setError("Future date not allowed")
}else{
cfDate.clearError()