Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Dynamic queries?

John Miller January 8, 2015

One of the ways my company uses Confluence is for field service reports of our machines. One of the things that has always been a pain is having to generate a table containing all of the client's machines for each report.

Is there a way to pass a dynamic variable to a PocketQuery query that will make this process easier?

Our data structure: a table containing company address, ID number, and list of machines.

Can I pass the company's ID, for example, to a query that pulls the machines for that ID and place it into a table for each Confluence page?

Just to clarify I know that I can already do this using a query containing the correct company ID, but the ID is just a number that does not change. Doing what I am attempting to accomplish in this way would mean that I'd have to create a new PocketQuery query for each company, which would amount to thousands of macros whose only different would be a number!

If not, do you have any suggestions about how I can tackle an issue like this?

EDIT: I was thinking about attempting to create a macro if it would give me the functionality I'm looking for. I know it is possible to embed macros within other macros, do you think I could do something like the following mockup using pocketquery if what I ask in the original question is not possible?

screenshotsample - Copy.gif

3 answers

1 accepted

1 vote
Answer accepted
Felix Grund (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 12, 2015

Hi John!

Didn't get a notification on this either. As Christian mentioned, you can make your parameters dynamic using the "Enable dynamic parameters" feature. Optionally, you can then check another checkbox "Use change params template" which will show a form above your result where you can change the parameters on the page. The page will then be reloaded with the appropriate GET parameters. If you have a custom template, and you want to include the "change params template" on your own, you can call this in your template:

$PocketQuery.template("get-params")

Let us know if you need further help!

Regards, Felix [Scandio]

Andrew Wolfe March 12, 2015

Should 'Use change params template' apply to the default template? I have both 'dynamic param' and 'use change params template' checked, and don't see any form.

Felix Grund (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.
March 12, 2015

Do you have parameters starting with ":" in your statement? Do you use a custom template for your query? If so, you'll have to enter the line $PocketQuery.template("get-params") on top of your custom template.

1 vote
Christian Koch January 12, 2015

Sorry for the late answer. Of course PocketQuery supports dynamic parameters. the plugin documentation http://www.scandio.de/en/atlassian/plugins-en/pocketquery-en/pocketquery-documentation/ explains as follows.

 

Dynamic parameters
(since version 1.11)
If you want to parametrize a PocketQuery macro dynamically when the page is loaded, you can make use of the “Enable dynamic parameters” feature. To enable this feature for a specific macro, check the “Enable dynamic parameters” checkbox in the macro parameters. This will also dynamically toggle another checkbox that enables to include a form in the template for changing the parameter values in the UI.

Dynamic parameters are passed as GET parameters to the page URL. For example, if you have a macro for a query with two query parameters “min” and “max”, you can open your page like this: [your-confluence-page-url]?pq_min=10&pq_max=50. All parameters must be prefixed with “pq_” to avoid naming collisions. Note that GET-Parameters precede the values you specified in the macro.

Christian

1 vote
Adrien Ragot 2
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 8, 2015

Founder of Play SQL here. With the (free) Play SQL Base plugin, you can define "User Parameters". It displays a form above the results.

John Miller January 8, 2015

We are pulling from a MySQL database, I do not see a reference to MySQL on your page, only Postgre. Does PlaySQL support MySQL?

Adrien Ragot 2
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 8, 2015

Correct. The main goal is to support PostgreSQL. MySQL is not officially supported. Sorry for intruding then.

John Miller January 8, 2015

Thanks for the suggestion! Perhaps in the future you will support MySQL :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events