We have a date customfield for "Desired delivery date". Our standard delivery time is 5 business days which is communicated lots of time but despite that they usually choose a date earlier than 5 days.
I want to create a behaviour to force the users to add a date which is 5 days or more from now. If they pick a date which is less than 5 days from now they will receive an errormessage.
You could use something like this
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.fields.CustomField def earliestDate = new Date().plus(5) def dateField = getFieldById(fieldChanged) def dateValue = dateField.value as Date if (dateValue < earliestDate ){ dateField.setError("Date cannot be earlier than (${earliestDate})") }
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could try something like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
def earliestDate = new Date().plus(5)
def dateField = getFieldById(fieldChanged)
def dateValue = dateField.value as Date
if (dateValue < earliestDate ){
dateField.setError("Date cannot be earlier than (${earliestDate})")
}
def addBusinessDays(Date date, int workdays) {
if (workdays < 1) {
return date;
}
def result = date;
int addedDays = 0;
while (addedDays < workdays) {
result = result.plusDays(1);
// Check if it's a weekday
if (!(result.getDayOfWeek() == DayOfWeek.SATURDAY ||
result.getDayOfWeek() == DayOfWeek.SUNDAY)) {
++addedDays;
}
}
return result;
}
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.