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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,006 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot