Set planned in tempo to 0 script runner

Rita YOUNES [Infosysta]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2016

Hello

Is there a way to set planned in tempo to 0 in a script post function.

 

In Fact I have calculated the Estimation time and when I want to cancel the issue I see that issue is on tempo .

I cleared original estimation and remaining estimation but the problem concist.

Please advise.

Rita

 

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 19, 2016

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

Rita YOUNES [Infosysta]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2016

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

Rita YOUNES [Infosysta]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2016

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,

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 23, 2016

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

0 votes
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 23, 2016

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

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 23, 2016

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

Rita YOUNES [Infosysta]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2016

@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

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 23, 2016

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

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 23, 2016

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

Rita YOUNES [Infosysta]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2016

Is there any way to remove the planned Time??

 

image2016-2-23 9:39:38.png

0 votes
Rita YOUNES [Infosysta]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2016

@Kristian Walker (Adaptavist) do you have any idea how I can do this ?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events