Hi, due to my very limited groovy / java(?) / scripting knowledge I'm unable to figure out how to do this. I have a (POST) script that sets the due date of an issue based on the detected status, which works fine so far. Now I would like to make the due date depend on the combination of the status and the selected option of a custom single select field called "Classification". Is this possible, and if so, could someone point me in the right direction? This is what I have so far (based on the status only):
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.config.ConstantsManager
import org.apache.log4j.Category
import java.sql.Timestamp;
// Init log
log = Category.getInstance("com.onresolve.jira.groovy.Belden-Set-DueDate")
// Init issue
MutableIssue myIssue = issue
// Define processing time based on status value
def statusVar = myIssue.getStatusObject();
def days = 0;
switch ( statusVar.name ) {
case 'Incomplete':
days = 1
break
case "New request":
days = 2
break
case "Request in progress":
// From now the days should be set depending on classification (A/B/C/E)
days = 2
break
}
// Turn amount of days into working days and set due date accordingly
if (days > 0) {
Calendar wdcal_duedate = Calendar.getInstance();
wdcal_duedate.setTime(wdcal_duedate.getTime());
def workingdays = 0;
while (days > 0) {
wdcal_duedate.add(Calendar.DATE, 1);
workingdays++;
if (wdcal_duedate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && wdcal_duedate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
days--;
}
}
Calendar cal_duedate = Calendar.getInstance();
Timestamp date_duedate = new Timestamp(cal_duedate.getTimeInMillis()+ workingdays*1000*24*60*60);
myIssue.setDueDate(date_duedate);
}
I hope someone can help me out. Thanks in advance!