Forums

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

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

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.

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
TAGS
atlassian, confluence administration, confluence admin training, confluence learning path, manage users and permissions, confluence certification, atlassian learning, cloud admin tools, streamline collaboration, confluence admin best practices

🚨New Confluence Admin Course Alert!

Manage Confluence like never before! This new learning path teaches you how to manage content, users, and permissions while optimizing user experience. Built for admins at all levels who want to confidently lead and unlock more innovative collaboration.

Learn more
AUG Leaders

Atlassian Community Events