Secrets Behind SharePoint Online – Day 1

Published by Shantha Kumar on

There are lot of things happening behind the load of pages, webparts in modern SharePoint Online. And here I am going to decipher those secrets as much as can by day by day.

First we will start with SharePoint Online admin center. We have two look and feels, such as classic and modern views for the SharePoint Online admin center . Each will show different lists of Site Collections.

Classic View doesn’t shows the modern based site collections. It avoid it.

But modern view shows all the site collections which are created based on classic template and modern templates.

How it is possible. Because Classic view uses the classic model for retrieving the Site Collection information. Modern view gets the lists of Site Collections and its information from the List DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS

This list is present in the SharePoint Online admin center and which contains the details of Site Collections and its properties.

The Active Sites and Deleted Sites view calls the below API with CAML Query Respectively

Active Sites:

https://<tenant>-admin.sharepoint.com/_api/web/lists/GetByTitle(‘DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS’)/RenderListDataAsStream

CAML Query:

<View><Query><Where><And><IsNull><FieldRef Name=”TimeDeleted”/></IsNull><Neq><FieldRef Name=”State”/><Value Type=’Integer’>0</Value></Neq></And></Where><OrderBy><FieldRef Name=’Title’ Ascending=’true’ /></OrderBy></Query><ViewFields><FieldRef Name=”SiteId”/><FieldRef Name=”Title”/><FieldRef Name=”SiteUrl”/><FieldRef Name=”LastActivityOn”/><FieldRef Name=”StorageUsed”/><FieldRef Name=”StorageUsedPercentage”/><FieldRef Name=”StorageQuota”/><FieldRef Name=”SiteOwnerName”/><FieldRef Name=”SiteOwnerEmail”/><FieldRef Name=”SiteSecondaryOwnerName”/><FieldRef Name=”SiteSecondaryOwnerEmail”/><FieldRef Name=”ShareByEmailEnabled”/><FieldRef Name=”ShareByLinkEnabled”/><FieldRef Name=”AllowGuestUserSignIn”/><FieldRef Name=”Classification”/><FieldRef Name=”TemplateId”/><FieldRef Name=”TemplateTitle”/><FieldRef Name=”IsGroupConnected”/><FieldRef Name=”GroupId”/><FieldRef Name=”TimeCreated”/><FieldRef Name=”TimeDeleted”/><FieldRef Name=”NumOfFiles”/><FieldRef Name=”FileViewedOrEdited”/><FieldRef Name=”PageViews”/><FieldRef Name=”ExternalSharing”/><FieldRef Name=”PrimaryAdmin”/><FieldRef Name=”HubSiteId”/></ViewFields><RowLimit Paged=”TRUE”>30</RowLimit></View>

Deleted Sites:

https://<tenant>-admin.sharepoint.com/_api/web/lists/GetByTitle(‘DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS’)/RenderListDataAsStream

Caml Query;

<View><Query><Where><IsNotNull><FieldRef Name=”TimeDeleted”/></IsNotNull></Where></Query><ViewFields><FieldRef Name=”SiteId”/><FieldRef Name=”Title”/><FieldRef Name=”SiteUrl”/><FieldRef Name=”LastActivityOn”/><FieldRef Name=”StorageUsed”/><FieldRef Name=”StorageUsedPercentage”/><FieldRef Name=”StorageQuota”/><FieldRef Name=”SiteOwnerName”/><FieldRef Name=”SiteOwnerEmail”/><FieldRef Name=”SiteSecondaryOwnerName”/><FieldRef Name=”SiteSecondaryOwnerEmail”/><FieldRef Name=”ShareByEmailEnabled”/><FieldRef Name=”ShareByLinkEnabled”/><FieldRef Name=”AllowGuestUserSignIn”/><FieldRef Name=”Classification”/><FieldRef Name=”TemplateId”/><FieldRef Name=”TemplateTitle”/><FieldRef Name=”IsGroupConnected”/><FieldRef Name=”GroupId”/><FieldRef Name=”TimeCreated”/><FieldRef Name=”TimeDeleted”/><FieldRef Name=”NumOfFiles”/><FieldRef Name=”FileViewedOrEdited”/><FieldRef Name=”PageViews”/><FieldRef Name=”ExternalSharing”/><FieldRef Name=”PrimaryAdmin”/><FieldRef Name=”HubSiteId”/></ViewFields><RowLimit Paged=”TRUE”>30</RowLimit></View>

The above REST API and caml queries are used to render the items in the modern view. We can use these APIs to retrieve the Site Collection information.

https://<tenant>-admin.sharepoint.com/_api/web/lists/GetByTitle(‘DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS’)/items

To get active site collections,

<Where><And><IsNull><FieldRef Name=”TimeDeleted”/></IsNull><Neq><FieldRef Name=”State”/><Value Type=’Integer’>0</Value></Neq></And></Where>

To get deleted site collections:

<Where><IsNotNull><FieldRef Name=”TimeDeleted”/></IsNotNull></Where>

 


Leave a Reply

Your email address will not be published. Required fields are marked *