In the previous article, we saw how to Add a Quick Launch Link. In this article, we will be seeing how to Update Quick Launch to a Web in SharePoint Office 365 Programmatically using CSOM C#
namespace Console.Office365
{
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
UpdateQuickLaunch();
}
public static void UpdateQuickLaunch()
{
OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
string siteUrl = "https://*****.sharepoint.com/sites/communitysite/";
string userName = "Sathish@*******.onmicrosoft.com";
string password = "*******";
using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
{
Web web = ctx.Web;
ctx.Load(web);
NavigationNodeCollection quickLaunchCollection = web.Navigation.QuickLaunch;
ctx.Load(quickLaunchCollection);
ctx.ExecuteQueryRetry();
NavigationNode NavigationNode = quickLaunchCollection.Where(n => n.Title == "Heading4").FirstOrDefault();
NavigationNode.Url = "https://www.sharepointpals.com";
NavigationNode.Update();
ctx.ExecuteQueryRetry();
}
}
}
}
Happy Coding,
Sathish Nadarajan.
Leave a comment