Set filters on space attachments macro
Asked by Samuel Stephens:

**Problem**

I am trying to set filters for space attachments using the native Confluence macro for Space Attachments.

Currently I can filter in the page for extensions or labels. This filter however is non-persistent and is lost when navigating away.

**Solutions investigated**

*Stiltsoft - Table Filter*

I have tried using the Table filter macro from Stiltsoft to set the filter. This filters the table however doesn't exclude the parts of the table that don't satisfy the filter. In this example the pages with no data show and you have to click through the pages until you get one that contains data that satisfies the query.

*Stiltsoft - Table Transformer*

I have tried using the table transformer macro from Stiltsoft to set the filter with an SQL query as follows:

```
SELECT *
FROM T1
WHERE 'Name' LIKE "%.tr5"
```

Much like the previous example the pages still show as having returned no rows, leaving me to navigate to a page with filtered data.

**Need**

I need a way to SET the filter for the attachments. This would allow me to show a filtered view of attachments rather than manually searching each time.


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@Samuel Stephens](/t5/user/viewprofilepage/user-id/4627393),  

My name is Katerina and I'm from the Stiltsoft team: the Table Filter and Table Transformer macros are ours. The issue with the Space Attachments macro relates to the native pagination of the macro. Unfortunately, it remains after the filtration and you may see empty pages. Other tabular macros without pagination (for example, the Page Properties Report macro) are supported by our macros well.

comments: author: Samuel Stephens
body: Hi [@Katerina Rudkovskaya \[Stiltsoft\]](/t5/user/viewprofilepage/user-id/3738229)

You're correct, I think unfortunately until the space attachments macro receives an update from Atlassian with some additional filtering features I'll be unable to do what I intend.

The point you've raised however sound like it could be a workaround perhaps. Would I be correct, in theory, assuming I could place an attachments macro inside the page properties macro and then have a page properties report to collect them all?

I had thought from using it in my previous experience that it was based on the use of page labels, in this case perhaps the #attachments label?

Thanks!

Sam


author: Katerina Rudkovskaya [Stiltsoft]
body: Unfortunately, I don't think that your workaround will be successful. The Page Properties/Page Properties Report macros collect only one-row tables, other rows are simply dropped.  

Our Table Excerpt/Table Excerpt Include macros work similar to the Page Properties Report macro but collect multiple-row tables. But again we won't get rid of the native pagination.  

There are also other apps on the Atlassian Marketplace that allow you to work with attachments in a more convenient way - you may browse them.  
Our company also develops [Smart Attachments for Confluence](https://marketplace.atlassian.com/apps/1219123/smart-attachments-for-confluence?hosting=server&tab=overview&utm_campaign=table-filter-traffic-sources&utm_medium=answer&utm_vendorID=1216111) - you may look into it closely.


author: Samuel Stephens
body: Ah that's a bummer. I'll be sure to check out some other options though.

Thanks [@Katerina Rudkovskaya \[Stiltsoft\]](/t5/user/viewprofilepage/user-id/3738229)! :)


author: ts
body: We also would prefer to have the standard **space attachments macro** available without pagination for more flexible customizations on your own within table filter macros etc...

Is there anything in Atlassian's roadmap or backlog documented about this issues?


author: Fabio Racobaldo _Herzum_
body: Hi [@Samuel Stephens](/t5/user/viewprofilepage/user-id/4627393) ,

using the builtin Attachment Macro you could use Filename Patterns paramter in order to define which attachments should be retrieved.

|------------------------------------|-----|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Filename Patterns** `(patterns`) | all | A comma-separated list of regular expressions, used to filter the attachments by file name. Note that the parameter values must be regular expressions. For example: * To match a file suffix of 'jpg', use `.*jpg` (not `*.jpg`). * To match file names ending in 'jpg' or 'png', use `.*jpg`,`.*png` |

More information are available here <https://confluence.atlassian.com/doc/attachments-macro-97911315.html>. Did u try this approach?

Fabio

comments: author: Samuel Stephens
body: Hi [@Fabio Racobaldo _Herzum_](/t5/user/viewprofilepage/user-id/781528)

Apologies I probably should have added this in my 'Solutions investigated' section.

The built in attachments macro is limited to the page it's placed on only. I had a look at the confluence article for it and there's no way to extend it beyond a single page scope.

I'm trying to collect all attachments in a space and filter extensions from there.

Sam


Tags: attachment

confluence-server

filter

macro

server

stiltsoft

table

table-filter

table-filter-and-charts

table-transformer