Get a list of UserHistoryItem for a specific period of time

How can I get a list of UserHistoryItem for a specific period of time. Currently our plugin needs that functionality for internal business usage and what we have determined so far is we can call for example:
List<UserHistoryItem> issueHistoryItems = userHistoryManager.getHistory(UserHistoryItem.ISSUE, appUser);
to obtain a list of UserHistoryItem(s) but we can't find out how to restrict the period of time those changes occurred.

1 answer

1 accepted

User history does not contain data about the date it was created.

What do you exaclty want to achieve. Maybe there is a better approach which will allow you to filter by date.

Hi Boris,

I'd like to obtain user's activity for a specific timespan.

Any references to the API would be appreciated.

Many thanks

If by activity you mean any issue-related activity you can then use com.atlassian.jira.user.UserHistoryItem.getType() to filter out all items related to issues and the use com.atlassian.jira.user.UserHistoryItem.getEntityId() to collect all issue ids that were affected by a user action. Next use com.atlassian.jira.issue.changehistory.ChangeHistoryManager.getChangeHistoriesForUser(Iterable<Issue>, User) to get all com.atlassian.jira.issue.changehistory.ChangeHistory objects. The ChangeHistory has a getTimePerformed() method which you can use to apply filter by date/time period.


Have you got any idea why all the changeItems fields in the obtianed List<ChangeHistory> are null?

List&lt;UserHistoryItem&gt; issueHistoryItems = userHistoryManager.getHistory(UserHistoryItem.ISSUE, appUser);
        List&lt;Issue&gt; issuesUserActedOn = new ArrayList&lt;Issue&gt;();
        for(UserHistoryItem userHistoryItem : issueHistoryItems){
            Issue issueByString = issueManager.getIssueObject(userHistoryItem.getEntityId());
            Issue issueByLong = issueManager.getIssueObject(Long.parseLong(userHistoryItem.getEntityId()));


        List&lt;ChangeHistory&gt; changeHistories = changeHistoryManager.getChangeHistoriesForUser(issuesUserActedOn, ApplicationUsers.toDirectoryUser(appUser));

Output from the debugger:

  • [2] = {com.atlassian.jira.issue.changehistory.ChangeHistoryBatch$ChangeHistoryWithLazyLoadedChangeItems@27042}
  • this$0 = {com.atlassian.jira.issue.changehistory.ChangeHistoryBatch@26936}
  • changeHistory = {org.ofbiz.core.entity.GenericValue@27093} size = 4
  • [0] = {java.util.HashMap$Entry@27122}"id" -> "12871"
  • [1] = {java.util.HashMap$Entry@27124}"author" -> "svspkccjg"
  • [2] = {java.util.HashMap$Entry@27126}"created" -> "2013-11-19 13:36:07.0"
  • [3] = {java.util.HashMap$Entry@27128}"issue" -> "10274"
  • issueManager = {com.atlassian.jira.issue.managers.DefaultIssueManager@26937}
  • changeItems = null
  • user = null
  • userManager = {com.atlassian.jira.user.util.DefaultUserManager@26938}

... where you can see that changeItems = null;

The change items are lazy loaded so you should call some method and then check rather than just looking at the debugger

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

172 views 1 17
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you