Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Use confluence page properties in "Jira Issue/Filter" macro

Andreas Eder July 15, 2024

Hi,

is there a possibility to use Page properties as filter criteria in "Jira Issue/Filter" macro?

I have some confluence-pages where some information from jira issues is displayed using some Jira Issue/Filter-macros.

I'd like to define some filter criteria once in the page, all jira-filter should use this attribute.

e.g: 

  • all jira-filter should use a defined timestamp / date to display all items resolved before this date.

 

1 answer

2 votes
Roma Bubyakin _Wombats Corp_
Contributor
August 14, 2024

Hello @Andreas Eder

It seems that you have a quite special request
I can propose for it our app User Macro for Confluence Cloud

If I understand you correctly, you have a page. The page has page property. The page property should be used in JQL for searching (and representing) issues from Jira.

Here is how I did it with our app.

Our Jira and JQL with the word "site":
Jira_JQL_search.png

I have added to the target page property "filter" with the value "site"

Confluence_page_properties.png

And now the most interesting, I have created a new User Macro which

  1. gets "site" from the page properties
  2. make the search in Jira
  3. and represent tickets as a table
## the key of the property we are looking for
#set($propertyKey = "filter")

## get all properties for the current page
#set($properties = $ConfluenceManager.get("/wiki/api/v2/pages/${page.id}/properties").results)
## looking for our property one-by-one
#foreach ( $property in $properties )
## check if current property same as $propertyKey
#if ($property.key == $propertyKey)
## store the value int $filter variable
#set($filter = $property.value)
#end
#end

## setup JQL with the $filter value
#set($jql = "text ~ '${filter}' AND project = TEST ORDER BY created DESC")

## making Jira search
#set($issues = $JiraManager.get("/rest/api/3/search?jql=${jql}").issues)

## show results as a simple table
#set( $jiraUrl = $StringUtils.remove($baseUrl, "wiki/") )
<table class="aui aui-table-sortable">
<thead>
<tr>
<th class="aui-table-column-issue-key">Issue key</th>
<th>Summary</th>
<th>Status</th>
<tr>
</thead>
<tbody>

#foreach ( $issue in $issues )
<tr>
<td><a href="${jiraUrl}/browse/${issue.key}">$issue.key</a></td>
<td>$issue.fields.summary</td>
<td>$issue.fields.status.name</td>
</tr>
#end

</tbody>
</table>

On the app code looks much better

Jira_Issue-Filter.png

 

And the final result: list of issues listed on the page

Final_result.png

I hope, I understand you correctly and this is what you need.
User Macro app provides a lot of possibilities for custom logic, integration, and representation.

Regards,
Roman, CEO of Wombats Corp

Andreas Eder August 27, 2024

Hello Roman,

It's nearly a possible solution, we use confluence data center.

I'll search for possible macro-apps.

 

I hoped there is an other way to re-use jira-filters in confluence pages :)

We use confluence to report data periodically, this pages contains many jira-filters. The only difference are some filter criteria. (e.g. resolved-time, fix-version). Currently, I have to adapt any filter manually - on the one hand, this requires a certain amount of effort, on the other hand, there is a risk of error.

 

Regards,

Andreas

Roma Bubyakin _Wombats Corp_
Contributor
August 28, 2024

On DC you have User Macro out-of-the-box and can create that thing from the admin page

Like Andreas Eder likes this
Andreas Eder August 28, 2024

Thank you,

As far as I understood, I need a macro for each Jira-Filter.

I'll give this a try and test macros.

Roma Bubyakin _Wombats Corp_
Contributor
August 28, 2024

You can write one macro and then parametrize it via User Parameters

So on adding the macro, the user specifies a parameter (JQL or/and property-key)

One macro will fetch different data based on the User Parameter, however, display it with the same logic

I'm pretty sure that you can achieve it within DC User Macro.
In any case, you can reuse my code partially (it has ~80% compatibility).
The main pitfall is finding a way to fetch data from Jira into Confluence via macro...

Regards, Roman

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events