Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update original estimate via API without changes in history?

Sesegma Tsydypova September 23, 2021

I want to update Original Estimate field using Groovy in Scriptrunner that way changes will not appear in history.

I guess I need to retrieve TimeTrackingSystemField and use updateValue method, but i don't know what the code should be look like.

 

1 answer

0 votes
Nir Haimov
Community Champion
September 23, 2021

Hi,

I didn't test it but it should be something like this

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue

MutableIssue mutableIssue=issue
mutableIssue.setOriginalEstimate(3600)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(currentUser, mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false);

If it's not working, you should at list be able to manage your way from here :)

Sesegma Tsydypova September 24, 2021

Hello,

thanks for you kind help, but this method updates issue and traces changes in history. 

I know that customfield.updatevalue() method does what i want, but it's for custom fields, not for TimeTracking field. 

In documentation I saw a matching method

updateValue(FieldLayoutItem fieldLayoutItem, Issue issue, ModifiedValue modifiedValue, IssueChangeHolder issueChangeHolder)

, but there is 2 problems:

1. I dont know how to retrieve this field for an issue

2. And what modifiedValue should look like

Nir Haimov
Community Champion
September 26, 2021

Hi @Sesegma Tsydypova 

I tried this code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue

def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = issueManager.getIssueObject("KEY-1")
issue.setOriginalEstimate(3600)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false);

this does update the original estimation (but also update the history)

Nir Haimov
Community Champion
September 26, 2021

as far as i know, there is no way to update Jira ticket without history...

Sesegma Tsydypova September 30, 2021

Actually customfield.updatevalue() updates values of issue without history :)

And TimeTrackingField has same method, but i dont know how to use it

Suggest an answer

Log in or Sign up to answer