Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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)
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

Script.PNG

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

All you wanted to know about customer support KPIs

When working in customer support, it’s crucial to calculate, analyze and monitor specific numbers, called KPIs (Key Performance Indicators). They go hand-in-hand with customer satisfaction, problem d...

133 views 1 5
Read article

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