How to assign automatically a variable to a query in a template?

Fabian Casal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 18, 2024

I have a Confluence template. I want to put on the top of the template a variable to be use in 6 queries I have in the same template instead of to have to replace the value in every query each time the value changes.

2 answers

0 votes
Fabian Casal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 14, 2024

Based on what I understand,  this is only to be use in a text query and not in a JQL query.

Are there any way to do it to be use in a JQL query?

 

Humashankar VJ
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.
November 14, 2024

You're correct that Jira doesn't natively support using variables directly in JQL queries. You can try with options like utilizing built-in JQL functions, which act similarly to variables. For instance, functions like currentUser() and startOfDay() can be seamlessly integrated into JQL queries.

 For example, you can use the following query: "text assignee = currentUser() AND updated > startOfDay()". This allows you to dynamically reference values like the current user or start of day, enhancing your querying capabilities.

0 votes
Humashankar VJ
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.
November 6, 2024

Hi @Fabian Casal 

Assigning variables automatically to queries in a Confluence template can be achieved through a straightforward process.

  • First, create a variable in your page template for the desired value, using the /variable macro (e.g., "QueryParameter" as a Text variable type).
  • Next, insert this variable into each of your queries using the syntax $QueryParameter.
  • For instance, modify your original query from text query = project = "ProjectName" AND status = "Open" to text query = project = "$QueryParameter" AND status = "Open".

When someone creates a page using this template, they'll be prompted to enter a value for the QueryParameter variable, which will then be automatically inserted into all relevant queries. This reorganized approach eliminates manual updates across multiple queries.

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events