Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Pocket Query: Question on Dynamic Parameters

  • Is it possible to have Dropdown for parameters out of the box? I did some change to the template example and made it work but it's very rough. Needs lot of structuring.
<form method="get" class="aui pq-dynamic-parameter-form" action="">
  <button type="submit" class="pq-change-button aui-button aui-style aui-button-primary">Change!</button>
  #foreach($key in $queryParameters.keySet())
  #set($reqKey = "pq_$key")
  <div>
    <label for="$reqKey">$key</label>
    <select class="text" id="$reqKey" name="$reqKey" value="$!req.getParameter($reqKey)">
		<option value="CRITICAL">CRITICAL</option>
		<option value="MAJOR">MAJOR</option>
		<option value="WARNING">WARNING</option>
		</select>
  </div>
  #end
</form>
$PocketQuery.template("default")
  • When i try to draw a chart (Using Confluence Chart Macro and Using PC Templates to draw charts) with results of a query that has dynamic parameters, i don't see an option to change the parameter. I'd like to re-draw a chart based on changed parameters.
  • How do i provide value in LIKE clause using dynamic parameters?
  • How do i bring in Date Picker in the parameters?

5 answers

P5: DatePicker

Put this in your template:

<div class="field-group">
	<label for="input-date">Choose Date:</label>
	<input id="input-date" class="pq-datepicker" />
</div>

Then later in the script tag call this:

jQuery('.pq-datepicker').datePicker({overrideBrowserDefault: true});

P6: LIKE

1.) Full LIKE clause

Example Query:

SELECT Name, Population
FROM Country
WHERE Name LIKE :CountryNameFullLike

For CountryName "Germany" you could enter this in your macro, for example: %erma%

2.) Only part of the LIKE clause

SELECT Name, Population
FROM Country
WHERE Name LIKE CONCAT('%',:CountryNameMiddlePart,'%')

For CountryName "Germany" you could enter this in your macro, for example: erma

===

Let me know if this helps!

Felix,

In my initial question i asked for 3 points. On first one, discussion is going on. Could you please answer the remaining two i.e. 

  • How do i provide value in LIKE clause using dynamic parameters?
  • How do i bring in Date Picker in the parameters?

P4:

Actually, I think this is an issue very similar to this one: https://answers.atlassian.com/questions/32997105

Maybe you can first evaluate if this helps you?

I just found that it could be the JS Code in the template in my answer might not work in PQ >= 2.0.2. I asked the author of the question if it still works.

...I'm actually working on a better solution currently...

Communication on the other ticket ongoing. Please check...

Felix,

Since i had one field in the form, i hardcoded the field and here it is like.

<form method="get" class="aui pq-dynamic-parameter-form" action="">
  <button type="submit" class="pq-change-button aui-button aui-style aui-button-primary">Change!</button>
  <div>
    <label for="pq_Severity">Severity</label>
    <select id="pq_Severity" name="pq_Severity" selected="$!req.getParameter("pq_Severity")">
		    <option value="CRITICAL">CRITICAL</option>
        <option value="MAJOR">MAJOR</option>
        <option value="WARNING">WARNING</option>
		</select>
  </div>
</form>
<script>
PocketQuery.chart('BarChart', {
	title: "Alerts by Severity",
	width: 600,
	height: 400,
	bar: {groupWidth: "95%"},
	legend: { position: "none" },
});
</script>
  • The form works as expected when "Load Macro Dynamically" is Unchecked but the parameters does not get appended to the URL when is "Load Macro Dynamically" is checked.

My requirement is, based on the value of Severity Chosen, the char should get refreshed without page reload.

Any help on Dynamic Parameters with different form type elements would help. May be another article from your side on this would be beneficial from your side.

 

Felix,

Any views on above queries??

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Wouldn't it be nice to have this Jira-Confluence integration?

...ossibility became true in a not too far future, project/space access would be left in the hands of all team members. Don't get me wrong: I'd love it! However, it would also be nice to have a way in which j...

59 views 0 1
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