Convert PocketQuery template to cloud

Duncan Kinnear
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 16, 2023

We've just migrated our on premise Confluence server content to the cloud version, and our PocketQuery templates don't work anymore.

We were taking the results of a query which produces a list of Topics. These Topics refer to pages in the current Space (by title). We need to be able to create a table of links to the pages referred to by each Topic in the result set.

In our on premise server version I used $pageManager.getPage() to find the relevant page, but this seems to be deprecated. I tried converting it to using $contentService, but something is obviously wrong, because the page comes up saying there is a template exception. However, I can't seem to find where this exception is, so I don't even know what is going wrong.

Can someone tell me:

  1. How to do what we did originally with $pageManager?
  2. How to see the exception produced by the template?
  3. Where I can find more information about how to do these templates?

Thanks in advance.

 

For completeness, what we used to do in the server version was:

#foreach ($row in $result)
<tr>
<td class="confluenceTd">
#if ($$pageManager.getPage($page.spaceKey, $row.name)) ## page already exists
<a href="$row.name">$row.name</a>
#else ## page doesn't exist yet
<a class="createlink" href="${req.contextPath}/pages/createpage-entervariables.action?templateId=5308417&spaceKey=$page.spaceKey&title=${generalUtil.urlEncode($row.name)}&linkCreation=true&fromPageId=$page.id">$row.name</a>
#end
<td class="confluenceTd">
$row.experts
</td>
</tr>
#end

What I've tried in the cloud version is:

#foreach ($row in $result)
<tr style="border-bottom-width: 2px">
<td>
#set($pageFound = $contentService.find(new Expansion('version'), new Expansion('id')).withType(ContentType.PAGE).withSpace($page.spaceKey).withTitle($row.name).fetch().get())
#if ($pageFound) ## page already exists
<a href="$row.name">$pageFound</a>
#else ## page doesn't exist yet
<a class="createlink"
href="${req.contextPath}/pages/createpage-entervariables.action?templateId=6425065&spaceKey=$page.spaceKey&title=${generalUtil.urlEncode($row.name)}&linkCreation=true&fromPageId=$page.id">
$row.name</a>
#end
<td>
$row.experts
</td>
</tr>
#end

and with debug switched on, I get the error:

12:35:12.770 ERROR An error occurred during Template rendering: The Template renderer stopped because of an ExecutionException. 

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events