Update change history

stepstep January 28, 2020

Hello everyone!

Im trying to update change history in Script Runner->Script Console like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean
import java.sql.Timestamp
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.index.IssueIndexingService

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("key")
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "fieldname")
def issueManager = ComponentAccessor.getIssueManager();
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)

log.warn changeItems.get(1).getCreated();

changeItems.get(1).setCreated(new Timestamp(1576655013000))

log.warn changeItems.get(1).getCreated();

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false);

issueIndexingService.reIndex(issue)

 In logs i see new date after setCreated but when i check history in issue it's still the same.

 

Thanks.

3 answers

0 votes
Сергей Шутов December 7, 2023

1

0 votes
Jorden Van Bogaert
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.
January 28, 2020

Hi @stepstep 

I misunderstood your question initially I think.

If you're trying to change the "created date" of the issue, I'm afraid this isn't possible via scriptrunner. You'll have to update this via the database.

I could be wrong here, but I don't think Jira allows the modification, so the database would be the only option.

stepstep January 28, 2020

I need to update the date when user made changes (like set another status or cleared field). It is shown in History tab under issue.

Сергей Шутов April 30, 2021

I am also interested in this question.
Did you manage to find a solution?

stepstep May 12, 2021

No, but I think it could be done with database update. Did not try though.

Rob B
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.
June 24, 2021

Whats the database update mate?

0 votes
Jorden Van Bogaert
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.
January 28, 2020

Hi @stepstep 

I think you need to change the EventDispatchOption to ISSUE_UPDATED so that the update is properly registered.

Give it a try and let me know.

Kind regards
Jorden

stepstep January 28, 2020

Still doesn't work ):

Also tried to use issue.store()

Suggest an answer

Log in or Sign up to answer