1

When I click a button in home page it has to open the latest weekly buzz which is a pdf document and is located in document library.When ever they upload the new one it has to open up the new one. Could you suggest me how to do it.Thank you.

enter image description here

  • Which version of SharePoint? – Christophe May 1 '14 at 2:20
  • HI Christophe,I am using sharepoint 2013 – Sai May 1 '14 at 16:59
  • What is the meaning of the hierarchy in your diagram? A doc library cannot contain another doc library. – Christophe May 1 '14 at 18:19
  • I am sorry, I made changes to the hierarchy.Sample doc library has nested folders.Using sharepoint designer I am able to get the folders Weeklybuzz,Test1,Test2 .But I have to get the latest weeks pdf from nested folders. – Sai May 1 '14 at 18:33
  • 1
    Using such a hierarchy is usually a very bad practice, inherited from file shares. In SharePoint you should not need such folders (especially labelled by date). – Christophe May 1 '14 at 18:44
2

The simplest way is to create a filtered view that only displays the last uploaded document. In the view settings:

  • sort by modified date, descending order
  • limit the number of displayed items to one

Programmatically, you could use the REST services as you are on SP 2013, and proceed in two steps:

  1. retrieve the ID of the last modified document /_api/web/lists/getbytitle('Documents')/items?$sort=Modified%20descending&$top=1&$select=ID
  2. retrieve the url of that document. For example if the ID from the first step is 42: /_api/web/lists/getbytitle('Documents')/items(42)/EncodedAbsUrl
2

The simplest solution is to upload the document always with the same file name and overwrite the existing version.

If you need to retain a copy for each version, you may want to try the following.

Create a new document library called "DisplayDoc".

Create a workflow in the original document library that runs when a document is created.

The workflow will

  • delete a document in the DisplayDoc library called TheFile.pdf
  • copy the current document to DisplayDoc
  • rename the document in DisplayDoc that has the same name as the current document and assign the file name TheFile.pdf

Now all you need to do is to seed a file called TheFile.pdf in the DisplayDoc library and let the workflow in the other library run whenever a file is created.

On the home page you can create a link to DisplayDoc/TheFile.pdf and that never needs to change.

Tested and working in SP 2010. Should work along the same lines in SP2013

  • Another way would be to just switch on version history for the document library. +1 for the simplicity of this approach. – Christophe May 1 '14 at 17:24
  • 1
    Can the downvoter please add a comment? – teylyn May 1 '14 at 21:27
1

You can use SharePoint Designer to drop the Document Library View on the page and limit the results to 1.

Than sort the results based on Modified date field (descending)

You can choose different layouts available in SharePoint Designer for showing the single item and play with XSLT to customize the view..

Reference:

Change the number of records displayed in a Data View

  • Hi Arsalan,When I open the home page in sharepoint designer I am able to see in Dataview Sample doc library only.But i have to get the Latest doc which is in Sample doc library/weeklybuzz doclibrary/Latest doc – Sai Apr 30 '14 at 22:50
  • Hi All,I included an image which describes the current hierarchy.They upload the doc every week.I have to get the current weeks doc in current month. In home page When they click the button it has to open the current weeks pdf doc automatically. – Sai May 1 '14 at 18:02

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.