Hi,
I have a Date-Time custom field. I want to enforce that users set it to at least 3 days ahead of the present time. For example, if today is January 1st, this field should be set to January 4th or later.
I tried the following Scriptrunner behavior below. Added it is a server-side script to my custom field:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.customfields.impl.DateTimeCFType
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.jira.groovy.user.FieldBehaviours
def futuredate = new Date().plus(3)
def dateFld = getFieldById(fieldChanged)
def dateValue = dateFld.value as Date
dateFld.clearError()
if (dateValue < futuredate){
dateFld.setError("Requested Date cannot be before (${futuredate})")
}
It does not have a compile error, but does not enforce the behavior I want. Seems like nothing happens. Any ideas how to fix my script?