Hello, I am trying to create a scriptrunner field based on a user request to calculate a deadline date which should be a number of business days after the due date - the number of days depends on the prioritisation of the issue.
I have a basic concept working but am falling down at the ensuring the number of days added are "business days" i.e. excluding weekends.
The code I have so far has been included below:
import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
def customFieldManager = ComponentAccessor.customFieldManager
def AgreedDeliveryDate = customFieldManager.getCustomFieldObjectsByName("Agreed Delivery Date")[0]
def Prioritisation = customFieldManager.getCustomFieldObjectsByName("Prioritisation")[0]
def PrioritisationValue = issue.getCustomFieldValue(Prioritisation).toString()
def sdf = new SimpleDateFormat("yyyy-MM-dd")
def AgreedDeliveryDateValue = sdf.parse(issue.getCustomFieldValue(AgreedDeliveryDate).toString())
if(PrioritisationValue == "Urgent") {
AgreedDeliveryDateValue + 1
} else if(PrioritisationValue == "Priority") {
AgreedDeliveryDateValue + 2
} else if(PrioritisationValue == "Routine") {
AgreedDeliveryDateValue + 2
}
Any advice would be greatly welcomed.
Kind Regards,
David