0

Scenario: The school lunch lady creates the monthly lunch menu in a PDF file (this is a given). She uploads this PDF to the SP2013 library called LunchMenus (file name could be 'Lunch Menu July 2015.pdf'. From the intranet home page a link to a 'site page' called 'Monthly Menu' contains a webpart (with an embed object) that displays a PDF from the library.

Currently, it's 'fixed' at displaying a file called 'Current Menu.pdf' and the lunch lady has to rename the monthly menu to 'Current Menu' in order for it to display. Ideally the embed object webpart could simply access the most recent menu and display the PDF despite what it's name is.

Is there a method for displaying the most recent PDF from a library in a webpart?

3

I would create a new view in the library, sorted by modified date descending, with an item limit of 1. This will get you the most recent file in your view that you can use in the web part on the home page.

  • you beat me to it :) – spStacker Sep 14 '15 at 18:49
  • He's hardcoded the link to the PDF file to display it so I don't think this'll help. He either needs to use CSR with this view or REST api to retrieve the most recent pdf file URL and feed it to the object. – Akhoy Sep 14 '15 at 18:56
  • Based on this, that doesnt seem to be the case: From the intranet home page a link to a 'site page' called 'Monthly Menu' contains a webpart (with an embed object) that displays a PDF from the library. – Eric Alexander Sep 14 '15 at 19:01
  • Correct Akhoy and Eric. I was hoping my hardcoded reference could point to a view that returned the "latest modified" file reference, then that reference would be the file to display in the embed. I might have to resort to Javascript and CSR. – Landfall Sep 14 '15 at 21:16
0

Well what you can do is Create a view called LunchMenusViews. And set the following attributes in the view settings enter image description here

enter image description here

Add this view to the webpart. Now only the last item modified will show up in the view of the webpart.

  • I understand, but this will only display a "link" to the PDF document, not the contents of the PDF. – Landfall Sep 14 '15 at 21:10
0

Another option can be to rename the newly uploaded file to 'Current Menu.pdf' using designer workflow and renaming old files to something else.

  • Thanks P S. That's what I had originally and it works all right. I was hoping there was a more elegant solution without a workflow. I guess I'll keep it like this until I have time to dig into the REST and API option. – Landfall Sep 15 '15 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.