Check if list already exists or not using sharepoint 2013 client object model autohosted apps

In this post, we will discuss how to check if a list already exists or not use the SharePoint 2013 client object model autohosted apps.

Also you can check out my previous posts on:

Rename default Name column in SharePoint 2010 document library

Unable to load workflow actions from server SharePoint Designer 2010

Add Custom Actions to List Item Menu in SharePoint 2010 Using SharePoint Designer 2010

Below is the full code to check if the list is already exists or not.

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

using (var clientContext = spContext.CreateUserClientContextForSPHost())

{

/*——————–Check the list if aalready Exist———————*/

ListCollection listCollection = clientContext.Web.Lists;

clientContext.Load(listCollection, lists => lists.Include(list => list.Title).Where(list => list.Title == “Thought_Of_The_Day”));

clientContext.ExecuteQuery();

if (listCollection.Count > 0)

{

Response.Write(“List all ready exist…”);

}

else

{

Response.Write(“List not exist”);


}

}


You May Also like the Following SharePoint Online Tutorials:

About Navneet Singh

I am Navneet Singh, Working at C3it software solutions pvt. ltd. in Pune. My core skills are SharePoint 2013, Office 365, SharePoint 2010, SharePoint Designer, SharePoint Designer Workflow, Nintex Workflow, Infopath, Webpart, CSOM/SSOM, Power-shell, C#, ASP.NET and SQL Server.

View all posts by Navneet Singh →

Leave a Reply