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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Hi, 

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.

Mark

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)

Felix,

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();

where 

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
 tableData.addRow(data.rows[i].rows);
}
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">

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

</table>
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">?

thanks

Mark

 

Hi Mark,

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

&lt;script&gt;
PocketQuery.chart('Table', {
	dataTable: [
		['Column 1', 'Column 2', 'Column 3'],
		[11, 12, 13],
		[21, 22, 23],
		[31, 32, 33]
	]
});
&lt;/script&gt;

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. 

Mark

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

568 views 7 22
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you