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 to access Scroll Version workflow using Velocity script

Hi there,

We are using Scroll Version on a Confluence space to do space version control. We have activated workflow provided by Scroll Version. We would like to access the workflow, namely the page status (draft, review etc) using a Confluence User Macro (written in Velocity code) to show the revision statuses of all the pages in a table. Can someone suggest a way to do that (i.e. to detect the revision status from workflow) please?

Thanks in advance for your help.


2 answers

0 votes
Dominic Lagger Community Leader Oct 14, 2020

Hi @Kin Chan 

I once wrote an user macro for getting the page keys. 

I get the API requests from the documentation page:

The code of my macro is here, feel free to adjust the way you need:

## Macro title: My Macro

## @noparams

#set( $pageId=$content.getContentId().asLong() )
#set( $listOfDescendants = $content.getDescendants() )

#set($listOfDecendantsPageIds = [])
#foreach ($page in $listOfDescendants)
#set($foo = $listOfDecendantsPageIds.add($page.getContentId().asLong()) )

<table class="confluenceTable tablesorter tablesorter-default" >
<thead class="tableFloatingHeaderOriginal">
<tr role="row">
<th class="confluenceTh">Page name</th>
<th class="confluenceTh">Page key</th>
<th class="confluenceTh">Version</th>
<tbody id="pk-table-output"></tbody>

let baseUrl = Confluence.getBaseUrl().concat(Confluence.getContextPath());
let spaceKey = AJS.Meta.get("space-key");
function pkArray(pkPages) {
var pkTable = "";
var i=0;
var list = $listOfDecendantsPageIds;
while (i < pkPages.length) {
var page = pkPages[i];
if( list.includes(page.confluencePageId)) {
if (page.scrollPageKey != undefined) {
pkTable = pkTable.concat("<tr role='row' ><td class='confluenceTd'><a href='"+baseUrl+"/pages/viewpage.action?pageId="+page.confluencePageId+"'>"+page.scrollPageTitle+"</a></td><td class='confluenceTd'><a href='"+baseUrl+"/display/_PK/"+spaceKey+"/"+page.scrollPageKey+"'>"+page.scrollPageKey+"</a></td><td class='confluenceTd'>""</td></tr>");
pkTable = pkTable.concat("<tr role='row' ><td class='confluenceTd'><a href='"+baseUrl+"/pages/viewpage.action?pageId="+page.confluencePageId+"'>"+page.scrollPageTitle+"</a></td><td class='confluenceTd'>---</td><td class='confluenceTd'>---</td></tr>");
return pkTable;

let pkRequest = new XMLHttpRequest();"POST", ""+baseUrl+"/rest/scroll-versions/1.0/page/"+spaceKey);
pkRequest.setRequestHeader("Content-Type", "application/json");
pkRequest.send(JSON.stringify([{"queryArg": "scrollPageTitle", "value": "*"}]));
pkRequest.onload = () => {
if(pkRequest.status === 200) {
document.getElementById("pk-table-output").innerHTML = pkArray(JSON.parse(pkRequest.response));
else {

Regards, Dominic

Hi Dominic,

Thanks very much for the code. I am new to Velocity scripting and am trying to understand your code. Would you please point out which statement in your code get the revision status (i.e. draft, review or complete) of the page?



Hi Kin,

I have a user macro here which could be useful. It must be used together with the Scroll Page Tree macro and adds workflow states to that page tree using some simple Javascript REST calls:

## @noparams
let scrollPages;
let baseURL;
function buildLozenge(state){
if (state == "Complete") {
return "<span style='margin-left: 4px; opacity: 0.8;' class='aui-lozenge aui-lozenge-success'>Complete</span>"
} else if (state == "Review") {
return "<span style='margin-left: 4px; opacity: 0.8;' class='aui-lozenge aui-lozenge-moved'>Review</span>"
} else if (state == "Draft") {
return "<span style='margin-left: 4px; opacity: 0.8;' class='aui-lozenge'>Draft</span>"

let addWorklowStates = function(scrollPages){
let confPageId = $(this).attr("data-page-id");
let requestUrl = baseUrl+"/rest/scroll-versions/1.0/workflow/"+confPageId;

let wfRequest = new XMLHttpRequest();
let wfState;"GET", requestUrl);
wfRequest.setRequestHeader("Content-Type", "application/json");
wfRequest.onload = () => {
if(wfRequest.status === 200) {
let response = JSON.parse(wfRequest.response);
wfState = response.i18nName;

let addMissingWorkflowStates = function(){
let i = 0;
let waitForPagesToExpand = setInterval(function(){
if ($("div[data-macro-name='sv-pagetree'] li.node.type_change").not(".workflow-stated, .deleted").length > 0){
let expandedPages = $("div[data-macro-name='sv-pagetree'] li.node.type_change").not(".workflow-stated, .deleted");
} else{
if (i >= 50){
}, 250);

AJS.toInit( function(){
let waitForScrollTree = setInterval(function(){
if ($("div[data-macro-name='sv-pagetree'] li.node.type_change").not(".deleted").length > 0){
scrollPages = $("div[data-macro-name='sv-pagetree'] li.node.type_change").not(".deleted");
baseUrl = Confluence.getBaseUrl();
} else {
console.log("no scroll tree pages found, retrying...")


Just place this macro and a Scroll Page Tree on the same page and the output will look something like this:

Screen Shot 2020-10-15 at 08.37.15.png

Let me know if this works for you. If it doesn't the first thing I recommend to troubleshoot is the Confluence base url, depending on your settings the context path can be part of that or not.



Hi David,

Thanks for the code. I have not learnt javascript yet and would like to know more about your code. Would your code work if the pages I am interested to know the revision status of are not subpages of the one with the macro?



Hi Kin,

the code I shared always adds the workflow status for all the pages that are displayed in the Scroll Page Tree macro. In the Scroll Page Tree macro settings, you can configure the root page for example, which can be any page in a space, regardless of what page you include the Scroll Page Tree macro on.

So in short, any pages that can be displayed by the macro will have their workflow state added.



Hi Dave,

I have tested your script on a small space and it works. I just need to test it on a big space to see if it still works. As I am using Velocity script (stated in my original request) and have not learnt javascript, I now need to see how to do the rest of my task with javascript. I need to create a table with the revision status and add more info such as date of change and button for reviewer to click (to record the number and names of reviewers). Do you have any idea how to do that?

Thanks for your help so far.



Suggest an answer

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

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

125 views 0 3
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