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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am also interested in this question.
Did you manage to find a solution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Whats the database update mate?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.