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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • 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

User macro to get all versions of a page

Dominic Lagger Community Leader Dec 06, 2019

Hello community

I would like to create a user macro, which shows me a change history of all subpages.
For that, I first tried to get a change history for just one page. But that doesn't semm possible.

I found this documentation: public interface Versioned
But as you can see, you can only access to the latest version.

version_user_macro.png

Question

Is there any way to get all versions in a list?
Then I could extract informations like versionnummer, date, comment, editor.
And then I could display that as normal table.

Thanks for any help.

Regards, Dominic

3 answers

2 accepted

1 vote
Answer accepted

I think I found a solution by my own.

There is a function for the pageManager.

To get the pageManager, this is the script

#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') )

And now I can get all Versions with "getVersionHistorySummaries"

#set( $allVersions=$pageManager.getVersionHistorySummaries($content) )

And now, I can make my table like this:

<table>
<tr>
<th>Datum</th>
<th>Version</th>
<th>Beschreibung</th>
<th>Link</th>
<th>Bearbeiter</th>
</tr>
#foreach( $version in $allVersions )
<tr>
<td>$version.getLastModificationDate()</td>
<td>$version.getVersion()</td>
#if($version.getVersionComment())
<td>$version.getVersionComment()</td>
#else
<td></td>
#end
<td>$version.getVersion()</td>
#set( $allContributers=$version.getContributorSet() )
<td>
#foreach( $user in $allContributers)
$user.getFullName()
#end
</td>
</tr>
#end
</table>

And now, I have to iterate over all subpages, which should also be possible somehow :) 

Regards, Dominic

Hi Dominic,

since I know you're a PocketQuery user, you could try using this Query:

SELECT *
FROM CONTENT
WHERE CONTENTID = :@pageid
OR PREVVER = :@pageid
ORDER BY VERSION

Of course you probably want to write a custom template as well that renders the user keys into actual user links, etc. but I think this should get you the data you need.

Best regards,
Sven

Dominic Lagger Community Leader Dec 06, 2019

Hi Sven

This is also a great idea! I didn't think of using PocketQuery for that! Nice!

I also found a solution with the confluence API. 

But I will try this one, too. Thanks a lot

Regards, Dominic

@Dominic Lagger 

Can you tell the solution using API?

 

Thanks

Dominic Lagger Community Leader Apr 27, 2020

Do you mean for the pocketquery?

I would do it like this: 

You have to loop over all children from a page with a given pageid

GET /rest/api/content/{id}/child

And for every result you have to call the API again, for getting all childs of childs.

With that, use some template and converter action and you should be able to get it done. I have not implemented it via API nor via the PocketQuery SQL. But both would work I think.

Hope this helped

Hi @Dominic Lagger 

Do you mean a report like this? 

list showing versions last updated date and person.png

-Mike

Dominic Lagger Community Leader Dec 06, 2019

Hi Mike

Do you already have such a user macro or is this a plugin?

I'm not sure whether this is the thing I'm looking for. Because there you just have the pages with the version numbers. 

I'm looking for a table with, where every version of a page is one row with version comment and change date. 

For example, you have 3 subpages, every subpage has 5 versions. Then my table should show 15 rows with every version and every version comment.

Hi Dominic, 

I am using a plugin called QC Document for Confluence Cloud. 

It can't do what you require there with 15 rows. It is more for pulling the latest version from a page. 

You do seem to have a lot more control using Confluence Server, I do wish I had more access to the data using the query tool.

Cheers,

Mike

Indeed you do have much more control over Confluence Server than over Cloud. This is typical for all On-Premise vs SaaS software. However this also comes with all the costs of running and maintaining the software, which shouldn't be underestimated.

Like Mike Bowen likes this

Also regarding PocketQuery (if that's what you mean by query tool), It's still early days but we are actually working on a Cloud version! ;)

Of course in this case it wouldn't actually help, because you don't have direct access to the database of Confluence Cloud, but you could still use it for the REST API and build a custom report that way. :)

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

383 views 23 8
Join discussion

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