Forums

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

How to list limited number of recent page attachments

Ilze Karklina
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!
March 29, 2018

I would like to display a limited number of the last-modified/uploaded page attachments. For example, to generate a list of the latest 3-5 documents that have been attached to the page. If I use "Attachment table" I can limit the number of attachments to retrieve but the problem is that it's sorted by File name and not by modification date. However, "Attachments" macro allows sorting by date but then I have to display the complete attachment list. I can achieve the desired result by using "Content by Label" macro but I would like to avoid labelling each file.

Would you happen to know any work around to this?

Thanks,

1 answer

0 votes
Lauretha Rura
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 10, 2018

Hey @Ilze Karklina,

 

one of the workarounds that I could think of is by embedding SQL for Confluence plugin into your Confluence page:

select c.TITLE as Attachment_Name
from CONTENT c
join CONTENT c2 ON c.PAGEID = c2.CONTENTID
join CONTENTPROPERTIES cp on c.CONTENTID = cp.CONTENTID
join SPACES s on c2.SPACEID = s.SPACEID
where c.CONTENTTYPE = 'ATTACHMENT'
AND propertyname = 'FILESIZE'
AND c2.title = '<pageTitle>'
AND s.spacename = '<spaceName>'
ORDER BY c.lastmoddate
LIMIT 5;

I limit the results to 5 in this query, but you could modify the value too.

 

Hope this helps :) 

Ilze Karklina
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!
April 13, 2018

Thanks! I will try this! :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events