Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Custom date field (Action Due date) needs to update the custom text field(Action due week)e.g. 16W07

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)
// 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 = "";
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


0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

217 views 0 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you