Hi
I have the below script which works on a date field called "Target Date"
It requires tickets being created to have a 3 day leading time so they cannot set the target date to be today or in following 2 days as this is unrealistic expectation for delivery.
com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Date.*
import java.text.SimpleDateFormat
import java.sql.Timestamp
import java.text.DateFormat
duedatefield = getFieldByName("Target Date")
Date duedatevalue = (duedatefield.value<span> </span>as Date)
//today
def today =<span> </span>new Date()
def noticket =<span> </span>new Timestamp((new Date() +3).getTime())
if(duedatevalue.getTime() < noticket.getTime()){
duedatefield.setError("Note: All tickets require a 3 day leading time, if your ticket is urgent and is required to be actioned the same day please contact xxx@yyy.com")
}<span> </span>else{
duedatefield.clearError()
} import
I wanted to see if anyone can help me edit this script to only work on weekdays, ie - It will not factor in Saturday or Sunday. A example of the problem would be a user creating a ticket on Friday and setting the target date to be following Monday, where the team does not work the weekend, the earliest in this scenario should be the following Wednesday.
Thanks for any advice
Rich