EnjoySharePoint YouTube Channel

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.

Get Office 365 Enterprise E3 Or Business Premium Subscription & Try out all the features

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”);

}

}

Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint 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 →