Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to update issue history using java api?


I have to update issue's change history using java api. I succeeded to retrieve the ChangeItemBean via changeHistoryManager.getChangeItemsForField

However when setting the new value using setToString(), the update is not populated in the history.

Any idea?


1 answer

0 votes

I don't know if it's possible to change the history.

You can definitely read the history.
There is a method to clear the history.
And you can add to the history using the ChangeLogUtils.

But there is no updateChangeItem method to store/persist the ChangeItemBean that you've attempted to modify.

At best, you can retrieve a changeItem Bean, modify it, then store it as a new ChangeGroup/ChangeItem. But the old one will still be there.

Hi Peter,

Thanks for you reply

The goal behind history update is migrating duplicated storypoint to the default one. 

Any idea how to achieve that kind of migration?



Sorry, I don't know what you mean. Can you give more details?

Hi Peter,

The goal is to update the following history item by replacing story points obsolete 1,  by story point (default one)


story point.jpg



The only way to change this I think would be through making changes directly in the database and that's never recommended.

But presumably, this means that you had a customfield called story points that you renamed "story points_obsolete" but you now also have the default "story points" field created by jira software. After the new field was created, all your issues would have had to be converted from the old to the new field. The entry (New story points going from null to 7 should be listed). I am not sure what you think changing the field label in the history will do, but wouldn't it be best to show the entire actual history? 

Hi Peter,

From your point of view, what will be the best approach to copy all items history from from old to new field?



History item are associated with an issue object, not a custom field. The "fieldname" is just an attribute of a change item and has no direct link to that field.

My recommendation is to no copy the history. The only thing I would be comfortable recommended with regards to the issue history is to insert a single history change item that would document the change in the field name.

Something like

Field                  |   Old Value                    |    New Value
Field Replaced  |    story points_obsolete |    Story Points

This would allow a user to to follow the chronology of events

Hello Peter.
So how would one append to issue's history? I haven't found any method in java doc yet.

You'll want to use the ChangeLogUtils for that

Here is a couple of sample functions that uses that:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeLogUtils
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.history.ChangeItemBean
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.issue.IssueEventBundleFactory
import com.atlassian.jira.user.ApplicationUser
import org.ofbiz.core.entity.GenericValue

def createChangeLog(Issue issue, String fieldName,String oldValue,String newValue,ApplicationUser currentUser,String eventName,String commentBody="",Map params = [:]) {
def changeHolder = new DefaultIssueChangeHolder();
def changeItemBean = new ChangeItemBean(ChangeItemBean.CUSTOM_FIELD, fieldName, "", oldValue, "", newValue)
def changeGroup = ChangeLogUtils.createChangeGroup(currentUser, issue, issue, changeHolder.getChangeItems(), false);
dispatchEvent(issue, currentUser, eventName, changeGroup, commentBody, params)
def dispatchEvent(Issue issue,ApplicationUser currentUser,String eventName, GenericValue changegroup,String commentBody = "",Map params = [:]) {
def eventFactory = ComponentAccessor.getComponent(IssueEventBundleFactory.class)
def eventId = ComponentAccessor.eventTypeManager.eventTypes.find { == eventName }?.id
log.debug "Dispatching event $eventName ($eventId)"
def comment
if(commentBody) {
comment = ComponentAccessor.commentManager.create(issue, currentUser, commentBody, false)
def eventBundle = eventFactory.wrapInBundle(new IssueEvent(issue, currentUser, comment, null, changegroup, params, eventId, true))
ComponentAccessor.issueEventManager.dispatchEvent(eventId,issue, currentUser, comment,null, changegroup,params, true)
} else {
log.warn "No event found matching name: $eventName"

def issue = ComponentAccessor.issueManager.getIssueObject('JSP-1922')
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
createChangeLog(issue, "dummy field", "old dummy value", "new dummy value", currentUser, 'Issue Updated')

This will produce a history item that looks like this:


Like I_L_I_A likes this

Hello Peter,

         I am beginner in JIRA. So I wanted to know if there is any stable platform to connect from Java to JIRA without using REST API? Can I use native Java libraries or any other additional libraries to connect to JIRA?

The normal way to connect to Jira from Java is to create a plugin using the atlassian SDK.

If you want to connect to a Jira instance from outside of Jira then REST API is the only way.

There is a Java wrapper for the REST API, but I've never used it and I'm not a fan.

Is it possible to create changegroup using changeLogUtils with a specified timestamp? I can create the changeItemBean with timestamp. Unfortunately, when I create a changeGroup using the list of changeItemBean created, it make me a changegroup to now, but not the timestamp in changeItemBean 

I don't know. I never tried.

Suggest an answer

Log in or Sign up to answer