How can we help you today?

Connect ShortPoint Design Elements with SharePoint Hub Site Documents

Do you want to share the Hub Site documents on your associated sites? If so, then this article is for you! Follow the simple steps listed below and you will be able to connect to the documents of your Hub Site on the associated sites.


So, let’s start.


TABLE OF CONTENTS


Step 1: Determine the Department ID property


Either in your Hub Site or in your Associated site, open the Developer Tools Console.

In the Chrome browser, you can do this by simply pressing the F12 key. 


Alternatively, you can click the right mouse button anywhere on the page and perform these two steps:


1. Select Inspect from the drop-down list.


Inspect the browser


2. The Developers Tools panel will appear. Inside the Developer Tools, switch to the Console tab and type: _spPageContextInfo.hubSiteId

Get the hubsite ID


Your Department ID will now appear below the command. It contains numbers and letters divided by dashes in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (for example, 98b99eb0-ae82-abda-4fa7-a4e87defb95be).


Copy and paste the Department ID into a text editor and save for later.


Step 2: Prepare the REST API URL


The REST API URL is given below, but before we use it we must make two changes.


The Department ID you have copied in Step 1 should be pasted twice into the URL (replace parts highlighted with blue).


https://tenantname.sharepoint.com/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True AND (DepartmentId:{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} OR DepartmentId:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)'&rowlimit=1000&sourceid='40f080a5-da63-4dce-b33a-fdad0dc83d1c'&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt","pptx"," mpp","csv","txt")' 


Additionally, please substitute the part highlighted in red with your tenant name. Here is an example of what we have used in our case:


https://myawesomecompany.sharepoint.com/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True AND (DepartmentId:{98b99eb0-ae82-abda-4fa7-a4e87defb95be} OR DepartmentId:98b99eb0-ae82-abda-4fa7-a4e87defb95be)'&rowlimit=1000&sourceid='40f080a5-da63-4dce-b33a-fdad0dc83d1c'&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt","pptx"," mpp","csv","txt")'


Congratulations. Your REST API URL is now ready. This query is used to get all the items from your libraries/site collections.


Step 3: Insert a ShortPoint Element


From the ShortPoint Page Builder, select File Lists Design Element and press Insert.




Step 4: Connect


Open the File Lists settings by pressing the cog wheel.



Switch to the Connect tab and choose Rest API:



Paste the Rest API URL as created in Step 2 and click Connect.



The Connect button will turn to red Disconnect button if you follow all the steps correctly as shown in the picture.



Step 5: Map the fields


Switch to the Items tab and use the chain icon buttons at the right end of the fields to connect the items. 

Choose the necessary columns from the drop down and press Preview to check how your result will look like and/or Update to save the changes.


Note: If you want the file types icons to be displayed, select the option File type in the Link Field.


Click File Type in the link Field


Result


After you save the page, you will see the connected File Lists:


Preview the result


Useful Filters


You can use the below-mentioned queries if you want to skip any file type from the list of documents or if you want to exclude a site collection/ specific document library from the search result.


Filter file type, remove not required ones from fileExtension


Simply delete the file type from the query (e.g., "txt", "ppt", "xlsx"). 

Below is the example of a query, which returns us all the files except PowerPoint presentations (file types: .ppt and .pptx):

https://tenantname.sharepoint.com
/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True AND (DepartmentId:{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} OR DepartmentId:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)'&rowlimit=1000&sourceid='40f080a5-da63-4dce-b33a-fdad0dc83d1c'&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","mpp","csv","txt")'


Note: Do not forget to change your DepartmendId and your tenant name.

Exclude a site collection or a specific document library from the search result


Replace the SiteName part in the query with your site collection you would like to exclude:

https://tenantname.sharepoint.com/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True AND NOT Path:"https://tenantname.sharepoint.com/sites/SiteName/" (DepartmentId:{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} OR DepartmentId:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)'&rowlimit=1000&sourceid='40f080a5-da63-4dce-b33a-fdad0dc83d1c'&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt","mpp","csv","txt")' 

Replace the DocumentLibraryName part in the query with your document library you would like to exclude:


https://tenantname.sharepoint.com/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True AND NOT Path:"https://tenantname.sharepoint.com/DocumentLibraryName/" (DepartmentId:{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} OR DepartmentId:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)'&rowlimit=1000&sourceid='40f080a5-da63-4dce-b33a-fdad0dc83d1c'&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt","pptx","mpp","csv","txt")'


Note: Do not forget to change your DepartmendId and your tenant name.

Related articles:


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 31 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more