Can Pocket Query use Velocity variables?

I have a database that contains meta data for Confluence pages, referenced by the Confluence content id.

Is it possible to pass the content id of the current page to Pocket Query somehow, for example by using $content.getContentIdAsString()? The Bob Swift SQL plugin can do this.

3 answers

1 accepted

2 votes
Answer accepted

Hi Arne,

In that case, you'd need a wildcard parameter for the macro browser. According to the PocketQuery documentation, the following wildcards are available:

  • @userName – the username of the current Confluence user
  • @userFullName – the full name of the current Confluence user
  • @userMail – the email address of the current Confluence user
  • @page – the page title of the current Confluence page
  • @spacekey – the space key of the current Confluence page

Since there is currently no wildcard for the current page's ID, I implemented this improvement. Could you install this version of PocketQuery I created for you and test in the following way if it solves your issue...


SELECT ... WHERE val = :pageid AND ...

Then in the macro browser, you simply enter @pageid for the variable "pageid". If it doesn't work, please check the "debug" checkbox in the macro browser and report the error message shown.

Note that :pageid will actually be transformed to a string. So your statement will become like this:

SELECT ... WHERE val = '50' AND ...

If this must be a number instead, I'll have to look for another way. 

As soon as your issue is solved, I'll create a new release and upload it to the Marketplace. I'm looking forward to your feedback!

Regards, Felix (Scandio)


Excellent, the new version works and is exactly what we need. Thanks a lot.

Thank you Arne! I created the new version 1.14.7 and uploaded it to marketplace. You should replace the temporary version I sent you with this one. And if you like PocketQuery, we'd be very happy about a little review at the marketplace :)

Hi Arne,

Thank you for your interest in PocketQuery! This should be easy to achieve if you already have a custom template, since you have the current page object available as $page. This is the object of type com.atlassian.confluence.pages.Page and you can call all available methods on it. In your case, this will most probably be getId() or getIdAsString().

If you need to pass the ID as macro parameter to a PocketQuery macro, things are a little differently. In that case, please let us know!

Regards, Felix (Scandio)

Yes I need the page id in the SQL query, not in the template. My query looks somehwat like 'SELECT ... WHERE val=$page.getContentId() AND ...'

Please advise how to pass the value from the template to the actual SQL query.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


116 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you