2015-09-18

SharePoint 2016 and Office 365 now includes the Mount files or folders api using CSOM and JSOM.

The Javascript SP.MountPoint api allows us to create a shortcut url containing the link.

[InternetShortcut]
URL=https://***.sharepoint.com/_layouts/15/mountpoint.aspx?site=9377021dbbfe4c65bf2910274e2b5ca4&web=5f698c8ec9544498bea63d6e2dc6fb23&item=17cb837e3d204e3ebb3b650ac2922a7d

The above contains the link to the _layouts/15/mountpoint.aspx which takes the following parameters,

  • Site Id.
  • Web Id
  • Item Id

When clicked the link will redirect to the correct folder or file.

The example below creates the shortcut url in the specified folder using the JSOM and the equivalent CSOM is also available.

Initialise the parameters:

var context = SP.ClientContext.get_current();
var sourceWeb = context.get_web();
var sourceFolder = sourceWeb.getFolderByServerRelativeUrl("/sitepages/folder");
context.load(sourceFolder);
context.load(sourceWeb);
var targetSite = context.get_site();
context.load(targetSite);
context.executeQueryAsync(function(){},function(){});

Create the MountPoint:

SP.MountPoint.createMountPoint(context,   targetFolder, "Mount_Name", targetSite.get_id(),
sourceWeb.get_id(),
 sourceFolder.get_uniqueId());
context.executeQueryAsync(function(){},function(){});
  • The above script creates the Mount_Name.url file within the targetFolder for the specified sourceFolder.

(Visited 224 times, 1 visits today)

About the author 

Balamurugan Kailasam

Download 6 Free Ebooks (No email needed)

There are Beginner Ebooks on Power BI, Power Automate and Teams. 2 Microsoft Teams Governance Ebooks and a very popular Power Users Guide to SharePoint!