How to create List view in Sharepoint 2013/Office 365 using CSOM

In this article, we will learn  about  List view creation 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);

List customList = clientContext.Web.GetList(String.Format(“{0}/Lists/customList”, clientContext.Web.ServerRelativeUrl.TrimEnd(‘/’)));

customList.Views.Add(new ViewCreationInformation {
Title = “customList”,
ViewTypeKind = ViewType.Html,
ViewFields = new string[] { “Title”, “Name” },
SetAsDefaultView = true,
RowLimit = 25,
PersonalView = false,
Paged = true


Please check out my blog to delete-list-view-in-sharepoint-2013/office-365 in CSOM.

Hope it helps!! Happy Sharepointing 🙂

Leave a Reply

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