PocketQuery Dynamic Parameters with REST

Ryan Davis August 15, 2019

I've been looking around documentation for PocketQuery to find information on dynamic parameters using REST API queries but I can only seem to find examples for SQL queries. What I would like to do is enable dynamic parameters on my REST query so I can search through a list of names in a contact database without having to load up the entire database and just using a Table Filter macro. I see that in order to add in dynamic parameters you have to add in pq_ before the variable, but I am trying to filter on one of the columns that I am already pulling with my converter.

 

Can anyone help out?

1 answer

2 votes
Sven Schatter _Lively Apps_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 22, 2019

Hi @Ryan Davis

dynamic parameters are a macro option and don't have much to do with your query itself. By enabling dynamic parameters you're telling PocketQuery to look for parameters in the URL of your page to use in your query. So for example in this URL:

https://your-confluence.com/your-page?pq_year=2019

PocketQuery will pick up the year parameter and set it to 2019 if one of your queries in that page has a year parameter. Also see here for a further explanation.

I think what you are actually looking for are probably query parameters. You can define a query parameter in you query by using the colon syntax (e.g.: :myparam). This works both for SQL:

SELECT *
FROM customers
WHERE name = :name

and REST:

/customers/:name

By the way: You can also use so called wildcards. For example, if you want the name of the current page filled in automatically you could do:

/pages/:@page

You can find all available wildcards here. If you need specific help designing your query you can always raise a ticket at our HelpDesk for PocketQuery where we can help you with more details.

Hope that helps! :)

Best regards,
Sven

Georg December 3, 2019

We're just testing your pocket query addon.

Is it possible to pass a parameter directly to a SQL statement without filling the parameter field in the Pocket Query macro.

So far I've only managed to do it this way
In the query


       Select * from Bla where user = :userFullName
       userFullName = String

and must then set the parameter


       userFullName = @userFullName

so that the logged in user can see his data.

In your example above


     /pages/:@page

seems as if you could pass the parameters directly through or only refers to the REST call because the SQL statement doesn't work like this

Select * from Bla where user = :@userFullName

 

Georg

 



Sven Schatter _Lively Apps_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 3, 2019

Hi @Georg,

Yes, this is exactly what wildcards in Query statements are for! See them in the documentation: https://help.scandio.de/documentation/display/PQDOC/Queries#Queries-UsingParametersinQueries

:@userFullName may not work because wildcards might be case sensitive if I remember correctly. Have you also tried :@userfullname?

Cheers,
Sven

Georg December 3, 2019

Hi Sven,

that's it!
:@userfullname then runs as expected

Thanks

Georg

Sven Schatter _Lively Apps_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 3, 2019

Sweet! Should you encounter more questions don't hesitate to raise a ticket at our ServiceDesk. There you can also send us your concrete Queries, Templates and Converters privately. :)

Cheers,
Sven

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events