Active filtering of attachments
Asked by Agnes Kelemen:

Hi,

I am trying setup a page with different attachment types (Word, PDF, video files, etc.) and would like to have the option to search the entire page based on keywords/labels linked to the files.

I have tried to add labels to the files and then use the Attachment, Attachment space macro to try and see if i can have an active filtering based on the labels, but so far it is not working. Not sure what I am doing wrong. :(

As an example of what I am trying to achieve:

Overview page:

File 1 (label: red)

File 2 (label: red, blue)

File 3 (label: green)

Show a filter box on the page and when I type "red", I should only see File 1 and File 2, because they contain the labels/keywords. the rest should be actively filtered out.

Any help would be appreciated!

Thanks,

Agnes


Answers:
author: Ravya
body: Hi [@Agnes Kelemen](/t5/user/viewprofilepage/user-id/3998271) ,  

You can filter the page attachments using the attachment macro:  
![2020-07-06_21-49-39.png](https://community.atlassian.com/t5/image/serverpage/image-id/101851i7B789E6CA5F53857/image-size/large?v=v2&px=999 "2020-07-06_21-49-39.png")

If you have any file pattern you can use extensions like .\*pdf or so on.  

Or else you can use Bobswift's Advanced Tables app - Attachment macro as well, to filter out using labels:  

![2020-07-06_21-52-22.png](https://community.atlassian.com/t5/image/serverpage/image-id/101856i79C23AF17A6E041F/image-size/large?v=v2&px=999 "2020-07-06_21-52-22.png")![2020-07-06_21-52-14.png](https://community.atlassian.com/t5/image/serverpage/image-id/101857iCE075290EB05809F/image-size/large?v=v2&px=999 "2020-07-06_21-52-14.png")

Hope the information helps.  

--Ravya

comments: author: Agnes Kelemen
body: Hi [@Ravya](/t5/user/viewprofilepage/user-id/2912058)

Thanks for your reply.

I have tested these macros and from what I've seen these are pre-filtering the attachments, rather than allowing the user to actively search based on labels and then filter the documents out.

The goal is to give the end user the option to search for the attachments on their own, rather than me creating a filter based on certain labels and showing the attachments already grouped. We are trying to create a document repository, but we need to keep the search open to everyone, so we don't restrict what they see from the beginning. we need users to be able to find all attachments that have a certain label, when they are searching. Not sure, if this is possible in Confluence or not.

Thanks,

Agnes


author: Ravya
body: Hi [@Agnes Kelemen](/t5/user/viewprofilepage/user-id/3998271) ,  

Yes, you can achieve this using Bobswift's Run Self-Service Reports for Confluence app along with Advanced Tables for Confluence app.  

* Insert the Bobswift's Attachment macro in the confluence and set page filtering as per your requirement.  
  ![2020-07-14_10-30-56.png](https://community.atlassian.com/t5/image/serverpage/image-id/102770iDE651F739B6013F8/image-size/large?v=v2&px=999 "2020-07-14_10-30-56.png")  
  And in the Attachmnet filtering section for *Attachment label regex* add **$LABEL
  ![2020-07-14_10-32-02.png](https://community.atlassian.com/t5/image/serverpage/image-id/102771i1B0EFDC9CB329B75/image-size/large?v=v2&px=999 "2020-07-14_10-32-02.png")**
* Insert a RUN WITH A USER FORM AND PARAMETERS macro which comes from Run Self-Service Reports for Confluence app. And edit the macro and add field though the option available.  
  Delete the field Group which is not useful for you in this case. And in the Field Type add Text and for **Field Key** add LABEL:  
  ![2020-07-14_10-39-10.png](https://community.atlassian.com/t5/image/serverpage/image-id/102773i11E1A10540F565AA/image-size/large?v=v2&px=999 "2020-07-14_10-39-10.png")
* Now insert the attachment macro inside the RUN macro:  
  ![2020-07-14_10-41-49.png](https://community.atlassian.com/t5/image/serverpage/image-id/102774i154716FACC7BA0C3/image-size/large?v=v2&px=999 "2020-07-14_10-41-49.png")
* Now once you publish the page, you can see the option to insert the label name and once you click run, it will list out the attachments with specified labels:  
  ![2020-07-14_10-43-46.png](https://community.atlassian.com/t5/image/serverpage/image-id/102775i867AA850A3D90BFB/image-size/large?v=v2&px=999 "2020-07-14_10-43-46.png")

Hope it helps!

--Ravya


Tags: attachment

filter

label