I am already having the same function with Fields Due date and Release Week
If I update due date with 2019-03-08 the Release Week updates as 1910:5
Same requirement I need with Custom date field (Action Due date) needs to update the custom text field(Action due week)e.g. 16W07
Here we are using the custom script:
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import java.sql.Timestamp;
//import java.util.calendar.*;
//import java.text.SimpleDateFormat;
if(issue.getProjectObject() != null)
if(issue.getProjectObject().getId() != 11016)
{//Update ReleaseWeek with week Except for WH-PCR Project
Date date = issue.getDueDate();
String relYearWeek = "";
Calendar calUK = Calendar.getInstance(Locale.UK);
//Calendar calUS = Calendar.getInstance(Locale.US);
//if(date != null)
if(date)
{
calUK.setTime(date);
// calUS.setTime(date);
String dueDateYearUK = calUK.getWeekYear().toString().substring(2);
String dueDateWeekUK = calUK.get(Calendar.WEEK_OF_YEAR).toString();
String dueDateDayOfWeekUK = calUK.get(Calendar.DAY_OF_WEEK).toString();
String dayOfWeek = "";
if(calUK.get(Calendar.DAY_OF_WEEK)==Calendar.MONDAY)
dayOfWeek = ":1";
else if(calUK.get(Calendar.DAY_OF_WEEK)==Calendar.TUESDAY)
dayOfWeek = ":2";
else if(calUK.get(Calendar.DAY_OF_WEEK)==Calendar.WEDNESDAY)
dayOfWeek = ":3";
else if(calUK.get(Calendar.DAY_OF_WEEK)==Calendar.THURSDAY)
dayOfWeek = ":4";
else if(calUK.get(Calendar.DAY_OF_WEEK)==Calendar.FRIDAY)
dayOfWeek = ":5";
else if(calUK.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY)
dayOfWeek = ":6";
else if(calUK.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
dayOfWeek = ":7";
//relYearWeek = calUK.getWeekYear().toString().substring(2) + dueDateWeekUK.padLeft(2, "0") + ":" +;
relYearWeek = dueDateYearUK + dueDateWeekUK.padLeft(2, "0") + dayOfWeek;//":" + dueDateDayOfWeekUK;
// String dueDateWeekUS = calUS.get(Calendar.WEEK_OF_YEAR).toString();
// String relYearWeekUS = calUS.getWeekYear().toString().substring(2) + dueDateWeekUS.padLeft(2, "0");
// return "EU:" + relYearWeek + ", US:" + relYearWeekUS;
// relYearWeek = "EU:" + relYearWeek + ", US:" + relYearWeekUS;
}
def cfManager = ComponentAccessor.getCustomFieldManager();
def relWeek = cfManager.getCustomFieldObjectByName("Release Week");
if(relYearWeek != "" || (relYearWeek == "" && issue.getCustomFieldValue(relWeek).toString() != ""))
relWeek.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(relWeek), relYearWeek), new DefaultIssueChangeHolder());
}
If I am replacing the Date date = issue.getDueDate(); with Action Due Date I am getting an error
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.