I am trying to restrict the due date field by preventing users from setting the due date 24 hours from the date that they are attempting to create the ticket. I am using ScriptRunner to create a simple scripted validator. I have been successful in preventing ticket creation with the below script, but it prevents all tickets from being created (Im guessing it might have something to do with the sql import when im using postgres, but I couldnt find a postgres equivalent).
import java.sql.Timestamp
def duedate = issue.DueDate
def noticket = new Timestamp((new Date() +1).getTime())
duedate > noticket
issue.DueDate is invalid. Though the compiler doesn't flag it, it gets logged as an error. Try issue.getDueDate() instead.
Note that though the field is of type datetime, the interface accepts only a date, so the system will set the time to 0:00:00, meaning that if the user selects a due date of tomorrow, it will always fail; it will not fail for a due date of 2 or more days out.
e.g. if I create a ticket now with a due date of tomorrow
now = 2019-02-25 14:35
noticket = 2019-02-26 14:35
duedate = 2019-02-26 00:00
duedate > noticket returns false
but if I create a ticket now with a due date of day after tomorrow
now = 2019-02-25 14:35
noticket = 2019-02-26 14:35
duedate = 2019-02-27 00:00
duedate > noticket returns true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.