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

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

usermacro - get published date of page version

Hi there,

I try to create a usermacro for tagging pages with published version and timestamp from publishing. I have found the needed data in "Page History":


so my macro is look like that:

## @noparams
#set( $version = $content.version )
#set( $dateFormatter = $action.getDateFormatter() )
#set( $date = $content.getLastModificationDate() )
<strong>Version: </strong>$version, <strong>Ver&ouml;ffentlicht: </strong>$dateFormatter.formatGivenString("dd-MMM-yyyy hh:mm", $date)

problem is that the $date is always show that what the name says: the last mod date

In that example timestamp 08:04 instead of 07:48 ... version is matching so if there are unpublished changes I see the correct version but not the correct timestamp:


Anybody out there with a nice hint for get the correct published date?

1 answer

1 accepted

0 votes
Answer accepted
Dominic Lagger Community Leader Mar 18, 2021

Hi @Rick Rokosch 

I tried your user macro, because I was sceptical, that you get "12" for the version. What you do ist, get the version from the $content. And this will always return the latest version, So I do not understand, why this is "12" for you.

When I use this macro, it's always my last version. 

The other thing I'm asking myself: What do you want to achieve? 

The last version published is always the last version in the page history. An unpublished page isn't listed in the page history and will not be displayed. 

Can you try to explain your need again?

Wenn es für dich einfacher ist, kannst du auch in Deutsch deinen Wunsch erklären :) 

Thanks and regards, Dominic

Hi Dominic,

we (our management) use "comala document control" to get confirmations of readed pages. Now they get the condition to make the reader visible which version of the page he is reading and acknowledging. 

So we have the case that one page (published) is requestet for readacknowledge at a range of days and in that range the pagecontent will be changed by management (unpublished hanging in comala plugin workflow). That changes the lastmodificationdate.

The published state is not equal publish in confluence. I think it is a layer of histroy pages managed by comala plugin.  

The macro  should show the reader the published version and timestamp. So what I need is something like $content.getHistoryVersion($version).getLastModificationDate().

Dominic Lagger Community Leader Mar 18, 2021

Hi @Rick Rokosch 

Oh, okay, I see. So I will not be able to reproduce this without this plugin :)

What I can offer you is a method, where you can get all versions:

On a $page, you can call getVersionHistorySummaries().

Then you can loop over the histories like this:

#set( $childVersions = $pageManager.getVersionHistorySummaries($page.getEntity()) )
#foreach( $childVersion in $childVersions)
#set( $modDate = $childVersion.getLastModificationDate() )

Perhaps, this will help you.

Yes sir ! Great work ! That was what I am looking for: 

## @noparams
#set( $version = $content.version )
#set( $dateFormatter = $action.getDateFormatter() )
#set( $i = ($pageManager.getVersionHistorySummaries($content.getEntity()).size() - $version) )
#set( $childVersion = $pageManager.getVersionHistorySummaries($content.getEntity()).get($i) )
#set( $date = $dateFormatter.formatGivenString("dd-MMM-yyyy hh:mm", $childVersion.getLastModificationDate()) )

<strong>Version: </strong>$version, <strong>Ver&ouml;ffentlicht: </strong>$date

 I dont know why he needed the content entity instead of page entity but try and error was get the correct result.

Thanks a lot @Dominic Lagger :-)

Like Dominic Lagger likes this

Suggest an answer

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

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,399 views 7 29
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