I've tried both Scriptrunner validators and behaviors, but I'm not quite getting there.
I need to prevent users from submitting tickets where they select a date in the past. I'm using the Due Date field, but can replace it with a custom field instead if needed.
Thank you!
I asked Chat GPT and here is proposed solution:
Here’s a sample Groovy script you can use in a Script Validator on a transition (e.g. Create or Update):
import java.time.LocalDate
// Replace with your custom field ID or name
def dateField = getFieldByName("Start Date")
if (!dateField || !dateField.getValue()) {
return true // allow if field is empty
}
def selectedDate = dateField.getValue() as LocalDate
def today = LocalDate.now()
return !selectedDate.isBefore(today)
If Date is in the Past, this will block the transition and display a generic error. You can customize the error message by adding:
return selectedDate.isBefore(today) ? "The selected date cannot be in the past." : true
--
I hope that helps!
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.