Scroll Version page key in user macro
Asked by Dominic Lagger:

Hi all

We have [Scroll Version for Confluence](https://marketplace.atlassian.com/apps/1210818/scroll-versions-for-confluence). With this we are able to create multiple versions of one page.

We also can add a "[Page Key](https://help.k15t.com/scroll-versions/latest/use-page-keys-110528323.html)". A page key can be added manually.   
![image.png](/t5/image/serverpage/image-id/104600iB114E6B57D076C26/image-size/large?v=v2&px=999 "image.png")

Now I wanted to create a list of all pages in this space and their page key, if they have one.

But I don't see anything where this information is stored...

How can I get access to this information? I want to create an user macro.  
I'm using also ScriptRunner, so also a ScriptRunner solution is highly appreciated.

Regards, Dominic


Answers:
author: Matt Reiner [K15t]
body: Hi [@Dominic Lagger](/t5/user/viewprofilepage/user-id/601600)

Here is a custom user macro definition that might be helpful for you. Placing it on any page will render a table with all pages with keys, their keys, and the versions for the current space. You can restrict the page to not interfere with the rest of your documentation. To re-create it in your instance, select the following settings:

![Screen Shot 2020-07-22 at 14.51.53.png](https://community.atlassian.com/t5/image/serverpage/image-id/104780i66CA8E01F6DCDA0D/image-size/large?v=v2&px=999 "Screen Shot 2020-07-22 at 14.51.53.png")

In the Template part, enter the following definition:

```
## @noparams
<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>
? ? ? ? </tr>
? ? </thead>
? ? <tbody id="pk-table-output"></tbody>
</table>
<script>
? ? let baseUrl = Confluence.getBaseUrl().concat(Confluence.getContextPath());
? ? let spaceKey = AJS.Meta.get("space-key");
? ? console.log(baseUrl);
? ? function pkArray(pkPages) {
? ? ? ? var pkTable = "";
? ? ? ? var i=0;
? ? ? ? while (i < pkPages.length) {
? ? ? ? ? ? var page = pkPages[i];
? ? ? ? ? ? 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'>"+page.targetVersion.name+"</td></tr>");
? ? ? ? ? ? }
? ? ? ? ? ? i++; 
? ? ? ? }
? ? ? ? return pkTable;
? ? }

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

If this doesn't work for you, feel free to reach out to use: support@k15t.com.

comments: author: Dominic Lagger
body: Hi [@Matt Reiner \[K15t\]](/t5/user/viewprofilepage/user-id/2246048)

This works great, thanks!

Is there any possibility to get a list from all the pages, which doesn't have any page key?

Regards, Dominic


author: Dominic Lagger
body: I found a possible solution, but I'm not sure if it's correct:

Change the queryArg:

```
pkRequest.send(JSON.stringify([{"queryArg": "scrollPageKey", "value": "*"}]));
```

And change the if statement:

```
if (page.scrollPageKey != undefined) {
pkTable = pkTable.concat("HTML HERE");
}else{
pkTable = pkTable.concat("HTML HERE");
}
```


Tags: confluence-server

scriptrunner

scroll

scroll-versions

server

version