How can we help you today?

Connecting to Link Items from Document Library

After reading this article, you will learn how to connect your ShortPoint elements to Document Libraries and map item properties including links behind Link items.



Prerequisites

  1. ShortPoint is already installed on your SharePoint Online (Office 365)  or on premise environment.
  2. Make sure you are ShortPoint Designer.


STEP 1: Add a ShortPoint Design Element Into Your Page


Edit your SharePoint page, place the cursor into the desired space on your page and open the ShortPoint Page Builder


Choose any design element, Simple List (we have selected for this article) from the list of design elements, click the Connect tab and select the REST API connection from the Select Connection Type drop down list.




STEP 2: Configure the REST API URL


Add the following URL in the REST API URL field:

https://<Site URL>/_api/web/lists/getbytitle('<Library Name>')/items?$select=LinkFilename,EncodedAbsUrl,<Other Filed Internal Names>,Properties/vti_x005f_shortcuturl,Author/Name&$expand=Author,Properties

 Make sure you replace the tags from the above URL with the appropriate values from your SharePoint Site:

  • <Site URL> - The full URL of your site or sub-site where your Document Library is located.
  • <Library Name> - The Name of your Library (e.g. Documents).
  • <Other Fields Internal Names> - Make sure you add other fields from your Document Library which you wish to map into your design element. If you don't need other fields, just remove this tag.



STEP 3: Configure the Mapping Function


Click Enable Advanced Settings, scroll down to the Map Results function and add the following code into the text area:


var $ = shortpoint.$;
if(data && data.d && data.d.results){
 for(var i=0; i<data.d.results.length; i++) {
    if (data.d.results[i].LinkFilename.endsWith(".url")) {
       data.d.results[i].EncodedAbsUrl = data.d.results[i].Properties.vti_x005f_shortcuturl;
    }
 }
}

return data;



STEP 4: Connect to the REST API


Scroll down and click Connect. If you run into any error during the connection, make sure you replaced properly the tags from the REST API URL and Map Results function.




STEP 5: Map the Items From Your Document Library Into Your View


After you successfully connected to the REST API, go to the Items tab, select the mappings of your fields and click Preview.



The URL of your Linked Items will be stored in a property called EncodedAbsUrl. Map this property on the Link field in order to open your Link Items (external Links) when you click on the items in view mode.

Also, if you have in your library both Link Items and Documents, the same property (EncodedAbsUrl) will store the URL for both item types. 

Please, note that opening the link will download the document. In case you would like to open its content, you may add your document as a link item.


Note: when setting lightbox or dialog as Linking option, some websites might not be opening in an iframe.  It happens because some websites use x-frame options or a content security policy not allowing other websites to embed their pages.

STEP 6: Insert the Element on Your Page


Click Insert and check your newly added element. 




 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