How can we help you today?

How to Create a List that Displays All The Sites Your User Has Access To

With the REST API connection, you can showcase all the sites your user has access to. Follow the step-by-step tutorial to learn how.


sample site list


NOTEThe list will display different sites for each user, showing only the sites they have permission to access.

TABLE OF CONTENTS


Prerequisite


Step-by-step Tutorial

Follow the steps below to learn how to create a site list using REST API:


Step 1: Edit the ShortPoint web part

Go to the SharePoint page you want to use and click Edit:


Edit


Close the Toolbox:


close icon


Select the ShortPoint tag:


ShortPoint tag


Click the Edit Properties icon:


Edit properties icon


Step 2: Switch to Grid Mode


NOTEThe ShortPoint Connect feature is currently only available in Grid Mode.


Click the Switch to Grid Mode icon:


Switch to Grid Mode icon


Step 3: Edit the Design Element


NOTEBefore proceeding, make sure you already have an Icon List or a Simple List on your SharePoint page. For this guide, we will use an Icon List. 

Icon List



Hover over the design element you want to use and click the cogwheel icon:


Cogwheel icon


Step 4: Connect Design Element to REST API

Go to the Connect tab:


Connect tab


Select REST API:


REST API


Copy the code below and paste it in the REST API URL field:


/_api/search/query?querytext='contentclass:STS_Site'

paste in REST API URL


Turn on Enable Advanced Settings:


Enable advanced settings


Copy the code below:


function extractKeyValuePairsArray(dataArray) {
  return dataArray.map(data => {
    return data.Cells.results.reduce((acc, item) => {
      acc[item.Key] = item.Key != "Author" ? item.Value : item.Value.replace("Global Administrator", "").replace("SharePoint App", "").replace("System Account", "").replace(";", "");
      return acc;
    }, {});
  }).filter(x => x.WebTemplate != "SPSPERS");
}

const inputArray = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
const outputArray = extractKeyValuePairsArray(inputArray);

return outputArray;

Scroll down until you see Map Results and paste the copied code:


paste in map results


Click Connect:


Connect


Step 5: Map Items

Delete all default content:


delete default content


Use the link icon to map the properties you want to appear in the Title, Subtitle, and Link fields:


link icon


Below is an example of how we mapped the items we want to show in the Icon List:

  1. #Title in the Title field - will showcase the name of the site as the title.
  2. #Author in the Subtitle field - will display the site owner as the subtitle.
  3. #SiteName in the Link field - will redirect users to the actual site when they click on an item.


map items


(Optional) If you are using an Icon List, choose the icon you want to be displayed in the Icon field:


Icon


Step 6: Save

Click Preview to see how the list will look:


Preview


Click Update once satisfied:


Update


Select the eye icon to see your page in real-time:


eye icon


Save your changes:


Save


Congratulations! You've successfully created a list that shows all the sites your users can access.


sample site list


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 35 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