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:
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.