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

Your Points Tracker
  • 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
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?
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

Logged time not decreasing after deleting worklog

Hi everyone,
I have imported worklogs in JIRA (JSON importer) on different issues and there has been a mistake which requires us to delete all of them.
I have prepared a script to do that but when the worklogs get deleted, the time spent (Logged - on Time tracking panel) doesn't decrease.
I've done some tests and this only happens for the worklogs imported in JIRA. Worklogs created manually and deleted with the same script don't cause any problems. The imported worklogs deleted manually work ok too.
What is surprising is that when I run the delete worklog, I get in the activity list exactly what I should, including "Removed the Worklog Time Spent".
Just for the completeness of the information, for the delete, I am using the JIRA API Interface WorklogManager

boolean delete(com.atlassian.crowd.embedded.api.User user,
             Worklog worklog,
             Long newEstimate,
             boolean dispatchEvent)

It's not that I have a problem with the script, it IS working. Deletes the worklogs. Is there more that needs to be done?

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.worklog.WorklogManager;
import com.atlassian.jira.issue.worklog.WorklogImpl;
import com.atlassian.jira.issue.worklog.Worklog;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;

WorklogManager worklogManager =  ComponentAccessor.getWorklogManager();
Issue issue = ComponentAccessor.getIssueManager().getIssueObject("EPIC-3101");
Long newEstimate;
//take the issue and for each worklog, delete it (complete clean-up)
worklogManager.getByIssue(issue).each { WorklogImpl worklog ->
    //to get the remaining there was before this worklog
	newEstimate = issue.getEstimate()+worklog.getTimeSpent()
    worklogManager.delete(ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser(), worklog, newEstimate, false)

The activity is interesting, because for the same one script run it is one of these three (not same):

image2015-5-15 14:46:24.png

out of which only the last one seems correct. I logged something? Seriously, by deleting a worklog?

If you have any idea what might be happening here, please let me know. Thanks a lot.

1 answer

WorklogManager gives you an option to adjust the remaining estimate and time spent when the worklog is deleted. And you are updating those fields in your code.

If you want JIRA to auto adjust those values when the worklog is deleted, use WorklogService. See deleteAndAutoAdjustRemainingEstimate method.

Hi Jobin, thank you for the suggestion, I will immediately have a look at that. I am adjusting only the remaining estimate though, not touching the time spent, only reading it on the worklog itself. I thought that the logged time has nothing to do with estimates and that it will get auto-adjusted whatever you are using to delete a worklog. It gets deleted, so detract.

It is only adjusting the remaining estimate in the screenshot (to 4 hours. i.e 3+1). Timespent is reduced by the deleted worklog (3 hours). Anyways, WorklogService should do it for you.

Well yes, that is actually the point : "Timespent is reduced by the deleted worklog (3 hours)". It says so, but it doesn't DO that. I delete all of the worklogs and the Logged time remains the same. So I have 5 weeks logged on the issue with no worklog in the end. I will try the service though.

I am getting the same problem

Hi there,

I'm facing the same issue.
If I delete the worklog (), then it's delete from the issue itself.

private static void deleteWorklog(final long worklogId) {
WorklogService worklogService = ComponentAccessor.getComponent(WorklogService.class);
JiraServiceContext jiraServiceContext = new JiraServiceContextImpl(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());
WorklogResult worklogResult = worklogService.validateDelete(jiraServiceContext, worklogId);
worklogService.deleteAndAutoAdjustRemainingEstimate(jiraServiceContext, worklogResult, false);

The UI is reflecting that by not showing any logged time.
But if I then log a new time, the old value is added to the newly written.

public static void createWorkLog(final Issue issue, final Date date, final String comment, final double amount) {
WorklogService worklogService = ComponentAccessor.getComponent(WorklogService.class);
JiraServiceContext jiraServiceContext = new JiraServiceContextImpl(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());
int min = (int) Math.round(amount * 60);
final WorklogInputParametersImpl.Builder builder = WorklogInputParametersImpl.issue(issue).timeSpent(min + "m")
WorklogResult result = worklogService.validateCreate(jiraServiceContext,;
worklogService.createAndAutoAdjustRemainingEstimate(jiraServiceContext, result, false);

E.g: there have been 2 hours logged. After deleting the log entry using it's ID, the 2 hours are delete. After creating a new log entry with 1 hour, the logged time shows 3 hours. I've no idea why that happens.

Any ideas?


Suggest an answer

Log in or Sign up to answer

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