Business Need
You need an automated process that uses historical Timepiece data from previously completed work items in the project to estimate the work needed for a new work item and set a realistic due date.
Solution
“STATUS DURATION” report type of Timepiece, combined with Jira Automation, can be used for this purpose.
Step 1: Configure and Save the Timepiece Report
First, create a Timepiece report...
-
Open the Timepiece reporting page.
-
Select the project in which the support issues reside (Let’s presume you have selected the ABC project).
-
Any filter selection at this point works. The selection made at this stage is not critical, as it will be overridden later during the automation configuration.
-
-
Switch to the “STATUS DURATION” report type.
-
(Optional) Select your business calendar if you have one.
-
Create a consolidated column and add all statuses included in the development process to this column.
-
Configure the Report Options as shown below.
-
Set the "Show report as" option to "Average of value across issues" to calculate the team's mean velocity.
-
Leave the 'Group issues by' field blank. Leaving this field empty ensures that a single average is calculated for all the records selected by the user.
-
-
Go to settings and save it via "Save report parameters".
-
The parameter set name should be like “Target Due Date Report”
-
Make sure you select the "Share with everyone" option so others can use the param set as well.
-
Step 2: Create a Jira Automation & Set General Flow Details
Navigate to Jira Automation and start a new rule.
Before configuring the automation logic, you must define the administrative settings in the Flow Details section.
Step 3: Define Trigger and Conditions
Use the “Work item created” trigger to start the automation whenever a new work item is created. Since our goal is to analyze how long issues take to be completed in this project and add this information as a comment on the ticket, we initiate the automation at this specific event.
Step 4: Add Action - Timepiece: Run Report
After defining the trigger and conditions, add a “Timepiece: Run Report” action that will fetch the required data from Timepiece.
-
Select the report you created for this automation in the Report Settings field. Ensure that the report has been previously saved using the “Save Report Parameters” option.
-
You can adjust the JQL here according to the records you want to use for calculating the average duration.
Parameter Overrides
Override some report parameters with a custom JSON. We’ll override the report filter so it returns data only from historical work items in the same project, excluding the issue that triggered the automation.
Parameter Overrides:
{
"filterType": "customjql",
"customJql": "key != {{issue.key}} and project = \"{{project.name}}\" and type = {{issue.issueType.name}} and updated >= startOfMonth()",
"viewFormat": "Hours"
}
Step 5: Add Log Action (Optional)
Add a Log Action to your flow. This step is necessary if you want to monitor the automation and helps debug in the event of an error.
This action writes the entire dataset returned from the report as a log output, allowing you to see all available data at once.
Log Message: resultList: {{fetchedTimepieceResultList}}
Step 6: Create Variable
In this step, we extract the average duration of the “In Development” status from the dataset and assign it to the InDevelopmentDuration variable so it can be used in later actions. (The result dataset is already expected to include only one row so we can use the first one)
Variable Name: InDevelopmentDuration
Smart Value: {{fetchedTimepieceResultList.first().get("InDevelopment").asNumber}}
Step 7: Create Variable
In this step, the duration stored in the inDevelopmentDuration variable is used to calculate a new due date.
Variable Name: newDueDate
Smart Value: {{now.plusBusinessHours(InDevelopmentDuration.asNumber)}}
Step 8: Add Log Action (Optional)
Add a Log Action to your flow. This step is useful for monitoring the calculated due date and helps with debugging in case of unexpected results in the estimation logic.
Log Message: newDueDate: {{newDueDate}}
Note: For more details about the logging and debugging, see the documentation.
Step 9: Edit Work Item Fields
In the Edit work item fields step, we directly update the Due Date field using the data collected in previous steps. The Due Date field is updated with {{newDueDate}}, the recalculated date value computed in an earlier variable step.
Step 10: Add Comment to Work Item (Optional)
In this step, the automation adds a comment directly to the work item summarizing the calculation results. Using the data retrieved from the Timepiece report and the calculated variables, the comment shows the average resolution time for similar work items and the newly calculated target due date, providing clear visibility into the result for that specific work item.
The automation adds the following comment:
In the last month, in the "{{project.name}}" project, work items of type {{issue.issueType.name}} have been resolved within {{InDevelopmentDuration.asNumber().round()}} hours. They are targeted to be completed on {{now.plusBusinessHours(InDevelopmentDuration.asNumber).fullDate()}}
Step 11: Enable the Rule
Click the “Turn on rule” button to activate the automation.
Once enabled, the automation will automatically add a comment to new work items, retrieving the average resolution time from the Time in Status app based on previously completed work items in the project and providing visibility into the expected completion duration.