We have an "IT Change Management" project. The simple scripted validator is supposed to check to see if a custom field (date field) called "Outage End" will be within date/time of 2 other custom date fields, the "Implementation Start" and the "Implementation End". I also have another simple scripted validator called "Outage Start" which does very similar thing. So what I have works for this. Here's the script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField ImplStartField = customFieldManager.getCustomFieldObject("customfield_13933");
CustomField ImplEndField = customFieldManager.getCustomFieldObject("customfield_13932");
CustomField OutageStartField = customFieldManager.getCustomFieldObject("customfield_17037");
CustomField OutageEndField = customFieldManager.getCustomFieldObject("customfield_17038");
Date ImplStart = (Date)issue.getCustomFieldValue(ImplStartField)
Date ImplEnd = (Date)issue.getCustomFieldValue(ImplEndField)
Date OutageStart = (Date)issue.getCustomFieldValue(OutageStartField)
Date OutageEnd = (Date)issue.getCustomFieldValue(OutageEndField)
if (OutageEnd.after(ImplStart))
{
OutageEnd.before(ImplEnd) || OutageEnd.compareTo(ImplEnd) == 0
}
else
{
return 0
}
My problem is that on certain changes, there is no outage - so the requirement is now that I need to test to see if the "Outage End" field is null and if it is, bypass the if statement entirely, as a null value is acceptable. I would obviously do this with the "Outage Start" as well.