Hi Folks,
I am trying to make a custom field required based on the value entered into duedate. I am trying this script with a behaviour but it does not seem to be working. Any ideas.
// required import statements
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Date.*
// Get pointers to my date field and get its value as a date
def cf = getFieldByName("Due Date")
def cfval = cf.getValue() as Date
def cf2 = getFieldByName("Justify the level of the urgency")
def cfval2 = cf.getValue()
// get todays date
def today = new Date()
// get the date three months in the future
def twoMonthDate = today.plus(60)
// if the date entered is before todays throw an error
if(cfval.before(twoMonthDate)) {
cf2.setError("You must Justify the level of urgency")
cf2.setRequired(true)
}else{
cf2.clearError()
cf2.setRequired(false)
}