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
com.atlassian.jira.issue.worklog:
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.