How to delete List view in Sharepoint 2013/Office 365 using CSOM?
In this article, we will learn about List view deletion in Sharepoint 2013/Office 365 using CSOM. Below is the sample CSOM code to achieve the same.
ClientContext clientContext= new ClientContext(siteUrl);
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(userName, pwd);
Web web = clientContext.Web;
clientContext.Load(clientContext.Web, w => w.ServerRelativeUrl);
clientContext.ExecuteQuery();
List customList = web.Lists.GetByTitle(“EmployeeList”);
// Get the specific view by Title
View view = customList .Views.GetByTitle(“EmployeeView”);
// Delete the list view
view.DeleteObject();
// Execute the query to the server
clientContext.ExecuteQuery();
Please check out my blog to create-list-view-in-sharepoint-2013/office-365 in CSOM.
Hope it helps!! Happy Sharepointing