Create Quick Launch Link in SharePoint using JSOM

The example in this topic show how to use JSOM to Create Quick Launch Link in SharePoint

  • function CreateQuickLaunchLink() {
  •     // You can optionally specify the Site URL here to get the context
  •     // If you don't specify the URL, the method will get the context of the current site
  •     // var clientContext = new SP.ClientContext("http://MyServer/sites/SiteCollection");
  •     var clientContext = new SP.ClientContext();
  •  
  •     var oWeb = clientContext.get_web();
  •  
  •     var quickLaunchCollection = oWeb.get_navigation().get_quickLaunch();
  •  
  •     // New Object "NavigationNodeCreationInformation" to create Navigation link
  •     var oNavigationNodeCreationInformation = new SP.NavigationNodeCreationInformation();
  •  
  •     oNavigationNodeCreationInformation.set_title("Node Name");
  •     oNavigationNodeCreationInformation.set_url("Node URL");
  •  
  •     quickLaunchCollection.add(oNavigationNodeCreationInformation);
  •  
  •     //Load the client context and execute the batch
  •     clientContext.load(quickLaunchCollection);
  •  
  •     // Execute the query to the server.
  •     clientContext.executeQueryAsync(onsuccess, onfailed);
  • }
  •  
  • function onsuccess() {
  •     console.log("success");
  •  
  • function onfailed(sender, args) {
  •     console.log('Failed' + args.get_message() + '\n' + args.get_stackTrace());
  • }

Thank you for reading this article. This code was tested in SharePoint 2013

We value your feedback:

Page URL:

Name:

 

Email:

 
 

Feedback:

 

© 2019 Code SharePoint