There are two custom date fields Start date and Baseline start date. whenever the user select the Baseline start date and if Start date is empty then copy the Baseline start date value to start date.
import java.text.SimpleDateFormat
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
def baseLineStartDate = getFieldById(fieldChanged)
def startDate = getFieldByName("Start date")
def startDateValue = startDate.getValue() as Date
def baseLineStartDateValue = baseLineStartDate.value as Date
def simpleDateFormat = new SimpleDateFormat('yyyy-MM-dd')
if(startDateValue == null){
if(baseLineStartDate.value){
def startDateFormatted = simpleDateFormat.format(startDateValue)
def baseLineStartDateFormatted = simpleDateFormat.format(baseLineStartDateValue)
def message = """${baseLineStartDateFormatted}"""
log.debug("message is" + message)
startDate.setFormValue(message)
}
}
Please help to correct the Behaviour script