Community moderators have prevented the ability to post new answers.
Hi Rita,
Are you talking at the tempo timesheets plugin?
I have attached an example of some code below which can be placed as a post function on the transition and will removed will worklogs on the issue.
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.worklog.WorklogImpl // Get the current logged in user def user = ComponentAccessor.getJiraAuthenticationContext().getUser() // Get the current Issue def SubjectIssue = issue // Get the Manager classes required def issueManager = ComponentAccessor.getIssueManager() def worklogManager = ComponentAccessor.getWorklogManager() // Get the work log data def IssueWorkLog = worklogManager.getByIssue(SubjectIssue) // Work log deleting options Long newEstimate = 0 // the new estimate for the issue Boolean announceBool = 1 // Delete the current logs as the current user (User must be switched to directory type) for (work in IssueWorkLog){ worklogManager.delete(user.getDirectoryUser() ,work, newEstimate , announceBool) }
I hope this helps.
Thanks
Kristian
Hi Kristian, Excuse me for the error, When I cancel the issue ,the worklog should be deleted.
This action is not working even if the post function succeed
you have any idea why I have this ?I 'm using JIRA 7.0.2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kristian Walker (Adaptavist) . I'm still able to see the issue in tempo even when i cancel it .
I used the same code.
awaiting your help.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not believe it is possible to remove planned time as it is not time actually logged against an issue where as logged time is stored against the issue and can be removed.
The only way to get around to not having planned time in tempo would be to disable time planning in the tempo configuration as far as I am aware.
I hope this helps
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rita,
I have just tested this on JIRA 7 and it appears the API has changed slightly. I managed to remove workflogs from a test ticket in JIRA 7 using the modified code below
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.worklog.WorklogImpl // Get the current logged in user def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() // Get the current Issue def SubjectIssue = issue // Get the Manager classes required def issueManager = ComponentAccessor.getIssueManager() def worklogManager = ComponentAccessor.getWorklogManager() // Get the work log data def IssueWorkLog = worklogManager.getByIssue(SubjectIssue) // Work log deleting options Long newEstimate = 0 // the new estimate for the issue Boolean announceBool = 1 // Delete the current logs as the current user (User must be switched to directory type) for (work in IssueWorkLog){ // delete the worklog worklogManager.delete(user,work, newEstimate , announceBool) // Set remaining estimate - uncomment line below if needed //issue.setEstimate(newEstimate) // Set Original estimate - uncomment line below if needed //issue.setOriginalEstimate(newEstimate) }
I hope this helps
Thanks
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please share screenshots of what you mean?
When you say cancel are there other worklogs on the issue other than for the user who is logged in when executing the transition as the code above only removes worklogs for the logged in user.
Thanks
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kristian Walker (Adaptavist), I have an Issue ,What I'm trying to do that when I want to "cancel" this issue , I don't want to see the worklog in Tempo timesheet.
I have used your post function on the transition when I want to cancel an issue.But till now I'm able to see the log time in tempo even after the cancellation.
ScreenHunter_76 Feb. 23 16.16.jpg
I hope that I was clear.
Awaiting your feedback.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you confirm where on the transition the post function is placed along with a screenshot of the config of the post function and what is shown in the atlassian-jira.log file when you execute the transition?
Thanks
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also could you confirm if that is logged time or planned time you are trying to remove. If it is planned time then this code will not work as this code will only remove time that has already been logged for a user.
Thanks
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there any way to remove the planned Time??
image2016-2-23 9:39:38.png
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kristian Walker (Adaptavist) do you have any idea how I can do this ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.