Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,560,360
Community Members
 
Community Events
185
Community Groups

Post Function due date based on original estimate that triggers on transition

Trying to find a Post-Function groovy script that can accomplish the need to:

  1. set the "Due Date"
    1. Only count Monday to Friday as viable days
  2. based on the "Original Estimate"
  3. But only when the task transitions from "To Do --> In Progress".

 

I am guessing that i would need to call an event to store the "original estimate" and then add that to the "new Date()" and then copy that to the due date.

Something along the lines of:

import java.text.SimpleDateFormat;
import java.util.Date;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
Date dt = new Date();
long time = (dt.getTime()+(issue.get("timeoriginalestimate")/3600)/8);
String duedate = sdf.format(time);

Currently there are tasks that are estimated but cannot be started due to others in priority, therefore i cannot set a due date on an item.

 

2 answers

1 accepted

0 votes
Answer accepted

Found this thread in the forums:

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Post-function-to-update-due-date-to-14-days-in-the-future/qaq-p/618533

 

The solution that i came up with was to add the groovy script in the:

Post Function inside: To Do --> In Progress, so when the user moves the issue to in progress the following will fire:

 

Update parameters of the Scripted (Groovy) operation on issue (JMWE add-on) Function for this transition.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import java.sql.Timestamp;
int days = (issue.get("timeoriginalestimate")/3600/8);
Calendar dueDate = Calendar.getInstance();

while (days > 0) {
dueDate.add(Calendar.DAY_OF_YEAR, 1)
--days;
}

/* Adjust for weekends > set to following Monday */
int dow = dueDate.get(Calendar.DAY_OF_WEEK);
if (dow == 7) {
dueDate.add(Calendar.DAY_OF_YEAR, 2)
} else if (dow == 1) {
dueDate.add(Calendar.DAY_OF_YEAR, 1)
}

issue.setDueDate(new Timestamp(dueDate.getTimeInMillis()));

 

I changed the day stamp from "14 days", to instead point to the "timeoriginalestimate" instead which solves the issue of needing to set a due date on anything from a planning standpoint and not knowing when the issue will be completed by.  Instead the due date will now be auto filled in based on the time estimate.

0 votes
Swati Kahol
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 02, 2020

Hi @Christian 

We have recently published a kb article to add Orginal estimate to a date field using Automation for Jira. Hope this helps :)

https://confluence.atlassian.com/cloud/automate-due-date-of-an-issue-from-original-estimate-1021245282.html

Thanks
Swati

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events