Hello
Can you please help edit the code below?
Goal: I need to validate a datetime picker that user should be able to pick past date based on other field values. for ex. user should able to pick past date only if "optionA" is selected on Customfield1.
I am trying using scriptrunner behavior. Any answer or guidance would be highly appreciated. :-)
- "Change Request Type" field has Latent, Emergency and Normal values.
- Start-Time is a datetime picker.
// 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 chngRqstType = getFieldByName("Change Request Type");
def starttime = getFieldByName("Start-Time")
def stvalue = starttime.getValue() as Datetime
// get todays date
def today = new Date()
if (chngRqstType.getValue() == "Emergency" || chngRqstType.getValue() == "Normal" ){
stvalue >= today
}
else if {
starttime.setError(" If you would like to log ticket that release has been implemented, please select change request type as Latent")
}