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

InfoPath alternatives for form designing SharePoint

In this post we will discuss how to check if a list is already exists or not using 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

– Solution: Save Site as Template option not appearing under Site Action Section in Site Settings menu in SharePoint 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”);

}

}

Similar SharePoint 2013 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