Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I call a PocketQuery query from within a User Macro

Anders Borup January 25, 2018

Been trying to call a PocketQuery query from within a User macro, just can't get to work

The reason why I want to use a User macro is because I can't parse all the parameters to the query automatically using the standard interface.

1 answer

1 accepted

0 votes
Answer accepted
Carla Roocks (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2018

Hi Anders,

Thank you for using PocketQuery!

What have you tried so far and what does not work for you?

You should be able to render any PocketQuery macro within a user macro by adding its storage format. A basic pocketquery macro could look like this in storage format:

<ac:structured-macro ac:name="pocketquery" ac:schema-version="1"><ac:parameter ac:name="name">MyQuery</ac:parameter></ac:structured-macro>

You can also set parameters this way. If you need an example, go to a Confluence page where your PocketQuery macro is set, click on the three point icon on the top right and select "View storage format". Then you can copy the relevant section from there to your user macro and adjust what you need to.

Hope this helps!

Best regards

Carla

P.S.: The fastest way to reach us at Scandio is usually through our service desk, if you need immediate support.

Anders Borup January 26, 2018

Hi Carla,

Thank you for the quick reply.

I have tried using the same syntax, but didn't include all the right parameters, that why it didn't work :)

Is it possible to call to call the pocketquery macro in a button like below

<button class="aui-button" onclick="$PocketQuery ..... 

 

Just as an info (properbly obvious) I'm all new to Confluence and the way the plugins works.

 

Regards

Anders

Carla Roocks (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2018

Hi Anders,

Happy to hear my answer helped :) If you officially "accept" it, others can see that the questions is solved.

Some general info: The code you include in the user macro simply executes the macro and adds the resulting HTML to the page. So executing it on button click is not possible this way.

There is a way to include the PocketQuery macro dynamically, though, using the option "Dynamic load" and "Dynamic parameters" (find more here in the documentation). Depending on what you want to achieve, you will also need a custom PocketQuery template (see more here and in our Getting Started Guide and Templating Tutorial). I think the easiest way would be to manage the dynamic behaviour using these PocketQuery mechanisms and maybe some custom Javascript in your user macro.

Regards

Carla

Anders Borup January 26, 2018

Hi Carla

Thank you for your help. I'll try your suggestion.

Regards

Anders

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events