• Community
  • Questions
  • How to pass query parameters from within a template using the PocketQuery.queryArray command

How to pass query parameters from within a template using the PocketQuery.queryArray command


I am writing a Pocket Query Template that requires a SQL Query parameter (date value) to be passed to the command PocketQuery.queryArray() to allow it to query the DB twice with two dates to retrieve to sets of data for array manipulation. There are three other parameters that will get specified from the PocketQuery instantiation in the normal fashion.

Could you please give the code snippet to allow to do this.

I looked at $queryParameters which gives me the parameters within the template but not a means of modifying and sending it back via the JavaScript,

Much Appreciated,and thank you for your support.


P.S. I think PocketQuery is really good and are starting to get some good graphs and tables from it.


3 answers

Hi Mark!

Thank you for your interest in PocketQuery! I do not really understand your question just yet. PocketQuery.queryArray() just gives you the results of a query in JavaScript. The only parameter it receives is the name of the query for which you want to get the results. If you want to query the DB twice you will either have to use two PocketQuery macros, or you render another PQ macro from within the template using $PocketQuery.renderPocketQueryMacro.

Please clarify what you really want to achieve.

Best, Felix (Scandio)


Thank you for your answer and you've already pointed me in the right direction for the original issue, and have found an example using  $PocketQuery.renderPocketQueryMacro. Now I understand it further, I've managed for the application I have, to do just a single query to get all the data I require from the DB. I can then transform the data I require using JavaScript commands/functions, however I can't display the data from the <script> area like I can a pocket google chart using the following command:

PocketQuery.chart('Table', {
dataTable: ProcessTable

Since I don't know the format of the ProcessTable Array shown above. In standard Google Visualization commands it using this inbuilt format to display a table.

var tableData = new google.visualization.DataTable();


for(var i = 0; i < data.columns.length; i++) {
tableData.addColumn('number', data.columns[i]);

for (var i = 0; i < data.rows.length; i++) {
// Rows are a list of comma separated columns
var table = new google.visualization.Table(document.getElementById('task_etc_fluctuations-table'));
table.draw(tableData, options);

I could try and use this format, like in your example to create a new Pocket Query table of data from the single query

<table class="pocketquery-table confluenceTable">

  #foreach ($column in $columns)
  #foreach ($row in $result)
    <tr class="#if($row.Population < 60000000)low#{elseif}($row.Population > 80000000)high#end">
    #foreach ($column in $row)

But in may case I need two or three functions from the RAW data to the displayed data to get the result I require. Each function iterates over the arrays doing calculations

So could you please tell me the either:

The format of the array for PocketQuery to display a table, or allow it to use google visualization functions or how to pass the output of my JavaScript functions array to the this format

class="pocketquery-table confluenceTable">?




Hi Mark,

dataTable must be a two-dimensional array where every row is an array in the array. See this example:

PocketQuery.chart('Table', {
	dataTable: [
		['Column 1', 'Column 2', 'Column 3'],
		[11, 12, 13],
		[21, 22, 23],
		[31, 32, 33]

Does this help?

The best solution is to the keep the Pocket Query Template simple for tables, using simple if's to highlight or drop rows. Then have calculated fields in the DB Tables that are pre-calculated during table updates or in a separate process. 


Suggest an answer

Log in or Join to answer
Community showcase
Louis De Jaeger
Posted yesterday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

123 views 10 2
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot