Hello,
I am desperately trying to compare 2 dates from custom fields in the issue screen, but nothing happens and I can't find the problem in my code:
--------------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import groovy.time.TimeCategory
import java.util.Date
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import java.text.SimpleDateFormat
def cf1 = getFieldById("date 1") // EDIT: this was my mistake, getFieldByName should be used instead
def cf2 = getFieldById("date 2") // EDIT: SAME
Date DateVal1 = (cf1.value as Date)
Date DateVal2 = (cf2.value as Date)
if (DateVal1.getTime() < DateVal2.getTime()) {
cf2.setError("date 2 cannot be later than date 1")
}else{
cf2.clearError()
}
--------------------------------------------------------------------
Your help will be much appreciated!