Can I specify parameters to use in the Jira Issue/Filter macro, preferably from a combo box?

Brian_Mihok
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 16, 2020

I have utilized the Jira Issue/Filter macro in Confluence and it is incredibly useful.  However, I would like to be able to populate a few of the parameters within the JQL string dynamically, preferably using a combo box.  While I know that I could create individual filters for each combination, this does not scale well, especially for multiple options.

In the problem I'm addressing, I'm querying based upon assignee and a couple custom fields.  In the combo box, I'd like to have the people's actual full name, such as John Smith, but then when the option is picked, insert their username, such as jsmith.  I also have a statement month and year that I need to similarly translate.  I would like the user to select a month and year, say June in one combo box and 2020 in another, and then translate that to a corresponding date range tied to a custom field in JQL (AND "Purchased Date" > 2020-5-23 AND "Purchased Date" <= 2020-6-22).

I saw the following link, but it requires Scaffolding and Reporting, both of which are expensive: https://docs.servicerocket.com/reporting/user-guides/recipes/miscellaneous/injecting-parameters-into-the-jira-issues-macro

I also saw the Run macro (https://bobswift.atlassian.net/wiki/spaces/RUN/overview), but didn't see how to tie that into Jira.  I found a few similar items, but again, I want to use the values from the combo boxes to inform the JQL string to use in the Jira Issue/Filter macro.

This also seems to limit options such as Easy Dropdown (https://marketplace.atlassian.com/apps/1216797/easy-dropdown-menu-drop-down-selection?hosting=server&tab=overview).  The dropdown options are great, but I don't know how I could then tie the selections into the Jira Issue/Filter macro.

I suspect that I would need to write my own plugin to achieve the desired functionality, but could be missing something obvious.  Any assistance would be greatly appreciated.

3 answers

2 votes
Katerina Kovriga _Stiltsoft_
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.
October 1, 2020

Hi @Brian_Mihok ,

You may try to use the Table Filter and Charts for Confluence app. 

Wrap you Jira Issues macro in the Table Filter macro and set the required filters:

Jira 1.pngJira 2.pngYou don't need to change your JQL query in the Jira Issues macro - just show all the fields. Regular users will find (filter) everything they need in the view mode easily. 

Jira 3.png

0 votes
Balu Wagle September 4, 2023

Hello @t3knoid 

Sorry to revive this old post.

This is very helpful. I had one question though.

My project name has multiple words separated by spaces so in the jql I have to put double quotes around the name so this does not seem to worhk without the double quotes.

is there a way to add those around the $content.title ? I tried adding them directly around the $content.title but then is seems to take the actual string and not the evaluated value

0 votes
t3knoid September 30, 2020

I recently had to do something similar where I have a query that must be used in different but similar Confluence pages. The Jira macro worked fine, but you have to remember which query to use. Quite frankly, I just want the query obfuscated so that all the user had to do was add the new macro and it does what is needed. The Jira project tracks issues of a number of project. There is a field called "Project Name" that provides the project name. We have a Confluence page for each project using the value used in the Jira "Project" field as the page title.

Here's a really simple approach that I came up with wrapping the Jira macro that provides a total of the number of issues found. The query itself simply looks for all unresolved issues or a given project. The value for the "Project Name" field used in the query is derived from $content.title. 

Here's the code.

## Macro title: JQL Total Issues To Date 
## Macro has a body: N
## Categories: Reporting
## Description: Uses the Jira macro to show total issues to date of a project.
##
## @noparams
<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">JIRA</ac:parameter>
<ac:parameter ac:name="jqlQuery">project = MYPROJECT AND resolution = Unresolved AND "Project Name" = $content.title ORDER BY priority DESC, updated DESC </ac:parameter>
<ac:parameter ac:name="count">true</ac:parameter>
ac:parameter ac:name="serverId">9d3b3c3f-d5c9-38fa-b19f-fabc967a7dc3</ac:parameter>
</ac:structured-macro>

For your needs, you can add the necessary parameters the user can fill out and use the entered values to build the query. The changed macro would look like the following if I chose to prompt the user for the project name (the changed lines are italicized):

## Macro title: JQL Total Issues To Date 
## Macro has a body: N
## Categories: Reporting
## Description: Uses the Jira macro to show total issues to date of a project.
##
## @param projectname:title=Project Name|type=string|required=true|desc=The project name
<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">JIRA</ac:parameter>
<ac:parameter ac:name="jqlQuery">project = MYPROJECT AND resolution = Unresolved AND "Project Name" = $paramprojectname ORDER BY priority DESC, updated DESC </ac:parameter>
<ac:parameter ac:name="count">true</ac:parameter>
ac:parameter ac:name="serverId">9d3b3c3f-d5c9-38fa-b19f-fabc967a7dc3</ac:parameter>
</ac:structured-macro>
Balu Wagle September 4, 2023

Hello @t3knoid 

Sorry to revive this old post.

This is very helpful. I had one question though

My project name has multiple words separated by spaces so in the jql I have to put double quotes around the name so this does not seem to worhk without the double quotes.

is there a way to add those around the $content.title ? I tried adding them directly around the $content.title but then is seems to take the actual string and not the evaluated value

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events