I need help with a script to compare dates and return a value of the furthest date. Can someone please help with this. Thank you
If i understand you right, you have 2 customfields of type DATE and you want to compare them and return the furthest date?
For example:
Date A = 01/Nov/2018
Date B = 01/Dec/2018
if B>A return B?
If that is what you want, here the code for this:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dateA = customFieldManager.getCustomFieldObject("customfield_11111")
def dateB = customFieldManager.getCustomFieldObject("customfield_22222")
if (issue.getCustomFieldValue(dateA) > issue.getCustomFieldValue(dateB)) {
return issue.getCustomFieldValue(dateA)
} else {
return issue.getCustomFieldValue(dateB)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.