ShortPoint lets you display any type of documents from your SharePoint libraries. The most commonly requested connection that a user wants to achieve is to display recently and the most visited documents across your SharePoint pages. In this article, we will show you how to achieve this connection by using the REST API magic.
Note: ShortPoint Page Builder Live Mode was formerly known as Visual Builder and Grid Mode was formerly known as Wireframe Builder. Also, ShortPoint Page Builder version 7 and below are now referred to as Legacy Page Builder.
TABLE OF CONTENTS
- Prerequisite
- Step 1: Edit existing ShortPoint Design Element
- Step 2: Configure the REST API settings
- Step 3: Map the Items
- Result
Prerequisite
- You have files added in your SharePoint document library/libraries.
- You already have a ShortPoint Design Element added to the page.
- Make sure is ShortPoint installed on your SharePoint sites(s). We recommend you to always have the latest version installed. Visit our Download ShortPoint page and get the latest version of ShortPoint.
- Make sure you are a ShortPoint user with an active license.
Step 1: Edit existing ShortPoint Design Element
In edit mode, open the settings of your Design Element.
Info: Currently, configuring ShortPoint connections is only supported in the ShortPoint Page Builder Grid Mode. Make sure to switch to it, if you are in Live Mode:
Click the cog wheel icon as shown below:
- New ShortPoint Page Builder Grid Mode:
- Legacy Page Builder:
The Settings tab will open:
Step 2: Configure the REST API settings
In edit mode of your ShortPoint Design Element, you will be able to establish a connection from the SharePoint document library that you want to connect to. Please follow these steps below on how to proceed with the configuration.
2.1 Set up the REST API connection URL
Switch to the Connect tab and choose REST API from the connection options:
Note: To have an overview of ShortPoint connect features, you may visit ShortPoint Connect: Basic Tutorial.
In the REST API URL, paste the following URL (items highlighted with red requires editing) depending on the results that you want to get.
If you want to display recently visited documents in the entire tenant, use this REST API URL:
https://siteURL/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt"
,"pptx","mpp","csv","txt")'&sortlist='ViewsRecent:descending'
Or, if you want to display most visited documents in the entire tenant, use this REST API URL:
https://siteURL/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt"
,"pptx","mpp","csv","txt")'&sortlist='ViewsLifeTime:descending'
siteURL- should be replaced with the site URL (root site, site collection, subsite) where the SharePoint list is located;
For example, our REST API URL looks like this:
https://somewhatcompany.sharepoint.com /_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt",
"pptx","mpp","csv","txt")'&sortlist='ViewsRecent:descending'
Where:
- somewhatcompany.sharepoint.com is your SharePoint tenant;
- '&sortlist='ViewsRecent:descending' is your query to display recently visited documents.
- '&sortlist='ViewsLifeTime:descending' is your query to display most visited documents.
Note: If you want to refine the results to a specific site or multiple site, you have to add extra filters in the queryText:
By SiteId: AND (SiteId: 00000-0000-000-0000) OR SiteId: {00000-0000-000-0000-0001}
By Site path: AND Path: https://{your-site-path}
For example:
https://siteURL/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True AND (SiteId:{0000-000-0000-0000} OR SiteId:0000-00-000-000)'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls" ,
"xlsx","ppt","pptx","mpp","csv","txt")'&sortlist='ViewsRecent:descending'
Step 3: Map the Items
Switch to the Items tab:
Press the chain icon on the right of the Design Element field (for example, Title) and select which column of your SharePoint list/library correspond to it:
Note: To know more about items mapping, please check our ShortPoint Connect: Basic Tutorial.
You may click the Preview button to check the results:
Then click Update to save your changes:
Result
That's it! You will now be able to display most popular documents across your SharePoint pages. Here is how it may look like on your page:
Related articles: