Showing page version at LiveTable?

So I have a few AWM apps. There is no native option to show the version of a page.

So I thought maybe it would be possible to create a field that automatically shows the last version of the current document. And then show that field on the Live Table.

I haven´t found a way to edit the tables from the History Tab to see what code it uses to search for the version of documents.

Getting the version of a document is easy. Something like:

{{velocity}}
## Get the document if you don't have it already.
#set ($myDoc = $xwiki.getDocument('Path.To.Page'))
Version is $myDoc.version
{{/velocity}}

See XWiki Scripting API Reference (XWiki.org) for the full document API.

Hope this helps,
Marius

1 Like

Thanks Marius, it worked, but I noticed I made a terrible mistake by trying to use a field to show the version and use the field on the Livetable of the App.

Because it versioned ALL my pages created with the app, when they got a new field. Not sure it’s possible to return the version.

But anyway, as I want to show version of other pages in other AWM apps, I need to show the version without adding a field.

And I am failing at that.

So what I did was getting into the app main page (with the livetable) and editing it in Wiki mode.

It shows the velocity code for the table.

I changed it to be like this

{{velocity}}
#set ($columnsProperties = {
  'doccode': {},
  'doc.title': {"link":"view"},
  'doc.version': {},
  'departamentoResponsavel': {"html":true},
  'doc.creationDate': {},
  'doc.date': {},
  'doc.author': {"link":"author"},
  '_actions': {"sortable":false,"filterable":false,"html":true,"actions":["edit","delete"]}
})
#set ($options = {
  'className': 'Procedimentos.Code.ProcedimentosClass',
  'translationPrefix': 'procedimentos.livetable.',
  'tagCloud': true,
  'rowCount': 15,
  'maxPages': 10,
  'selectedColumn': 'doccode',
  'defaultOrder': 'asc'
})
#set ($columns = ['doccode', 'doc.title', 'doc.version', 'departamentoResponsavel', 'doc.creationDate', 'doc.date', 'doc.author', '_actions'])
#livetable('procedimentos' $columns $columnsProperties $options)
{{/velocity}}

Notice the third column is doc.version
However, the version doesn´t show and the title of the column gets all wrong
image

That’s simply because doc.version column is currently not supported https://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HAllacceptedvalues-1 . It’s not complex to add support for it, but it hasn’t been requested so far. You could open an issue about this at XWiki Platform - XWiki.org JIRA .

Yes, when you modify a class (the object structure) all existing objects of that type need to be updated (to have the new structure).

1 Like

Thanks, so my solution to show the version at the live table is actually the only one possible right now? (get it as a field and then show the field)

As for page versions… is there a way to artificially set them to a specific version, being an administrator? (so they match versions of the legacy DMS, or in this case return to previous version without really returning the page structure)

Yes. You used a computed field right?

There’s no UI to do this. You can probably hack the page history (document archive) but I’m afraid it can lead to unexpected side effects.

Ok, thanks Marius. I created the issue at Jira.

https://jira.xwiki.org/browse/XWIKI-21598?orderby=created+DESC%2C+priority+DESC%2C+updated+DESC