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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I get a list of version history using velocity in a user macro.

I am trying to make a user macro that has a table of strings showing the page version, published date, contributor, and comments.


I am trying to use the VersionHistorySummary from the ContentEntityManager interface to get a list of VersionHistorySummary objects. Then use a foreach loop for building the table content.


I have tried the velocity template below in the user macro. However, the getVersionHistory is not seems to return anything.



2 answers

1 accepted

3 votes
Answer accepted
Dominic Lagger Community Leader Feb 25, 2021

Hi all

I once wrote a really big user macro for something like this. The script gets all childs and its versions. Here is some code sample: 

#set( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )
#set( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )
#set( $containerManager=$getInstanceMethod.invoke(null,null) )
#set( $containerContext=$containerManager.containerContext )
#set( $pageManager=$containerContext.getComponent('pageManager') )
#set( $page = $pageManager.getPage($content.getId()) )

#set( $latestVersions = [] )

#set( $allVersions=[] )
#foreach( $child in $page.getDescendants() )
#set( $childVersions = $pageManager.getVersionHistorySummaries($child.getEntity()) )
#foreach( $childVersion in $childVersions)
#set( $modDate = $childVersion.getLastModificationDate() )

As far as I know, the getVersionHistory is not working. I think, I struggled as well, so I used getVersionHistorySummaries()

Regards, Dominic

Thanks so much!

It is so helpful!

Are you sure that your first call actually returns an ContentEntityManager? 

I'm doing something where I need to retrieve pages based on their pageId and I've tried to get a  ContentEntityManager using both your example above as well as 

#set ( $contentEntityManager = $containerContext.getComponent('contentEntityManager') )

without any luck. 

Maybe someone else has a suggestion?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence Cloud

Introducing Confluence Cloud for Microsoft Teams (Available for Preview!)

Hi Atlassian Community, Remote work has shifted how teams collaborate, and we’ve heard from many of you that Microsoft Teams has become mission critical to many of your workflows, from how you chat...

2,375 views 16 19
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you