We have created a custom date field and we want to prevent users from selecting a date in the prior month or even a date in the past.
Is there a standard way of achieving this or is there a plug-in that is available.
Any help would be appreciated...thanks!
If you are using this field only on workflow transitions, you can use some of the existing validators.
But if you want this field on the edit screens, you would need a new custom field type that does this validation. That will be a new plugin I guess.
Do you have the name of the existing validator that may work, all I see for Validators is Date Compare and Window dates that relate to the dates. Is it one of those?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't remember which one it was. Can you try Date Compare and validate your Date field is after updated date?
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.
If you want to use the Groovy Runner Script plugin to validate you could use this code which validates that the entered date/time is from this month or later. I'm not sure if existing plugins can check this exactly
import org.apache.log4j.Category import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.util.IssueChangeHolder import com.opensymphony.workflow.InvalidInputException // replace 10000 by number of date time custom field that must be validated def fieldname = "customfield_10000" ComponentManager componentManager = ComponentManager.getInstance() CustomFieldManager customFieldManager = componentManager.getCustomFieldManager() CustomField field = customFieldManager.getCustomFieldObject(fieldname) Date value = issue.getCustomFieldValue(field) Calendar now = Calendar.getInstance() Calendar entered_date = Calendar.getInstance() entered_date.setTime value if (entered_date.get(Calendar.MONTH) == now.get(Calendar.MONTH) && entered_date.get(Calendar.YEAR) == now.get(Calendar.YEAR)) return; if (now.before(entered_date)) return; invalidInputException = new InvalidInputException("Entered date is invalid! Must be from this month or later")
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.