How to create Promoted Links list in SharePoint 2013 using Client Side Object Model

Promoted Links list:

SharePoint 2013 introduced a new list template called Promoted Links. This list is used to store the links that has to be shown as a tiles format in the site. [To create Promoted Links list through UI go to Site Contents => Add an app => Promoted Links. To create Promoted Links list using Server Object Model please refer http://www.c-sharpcorner.com/Blogs/10938/programmatically-create-promoted-links-list-in-sharepoint-2.aspx]

In this blog you will see how to create Promoted Links list in SharePoint 2013 using client side object model.

Steps Involved:

1.       Open Visual Studio 2012 (Run as administrator).

2.       Go to File=> New => Project.

3.       Select Console Application in the Visual C# node from the installed templates.

4.       Enter the Name and click on Ok.

5.       In the solution explorer, right click on References folder and then click on Add Reference.

6.       Add the following assemblies from 15 hive (C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI).

a.       Microsoft.SharePoint.Client.dll

b.      Microsoft.SharePoint.Client.Runtime.dll

7.       Open Program.cs file and replace the code with the following

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Microsoft.SharePoint.Client;

 

 

namespace CreatePromotedLinksList

{

    /// <summary>

    /// Console Application

    /// Create a new Promoted Links list

    /// </summary>

    class Program

    {

        static void Main(string[] args)

        {p; {

            // Get the context to the SharePoint site

            ClientContext context = new ClientContext("http://c4968397007/");

 

            // The SharePoint web at the URL.

            Web web = context.Web;

 

            // Get the list template by name

            ListTemplate listTemplate = web.ListTemplates.GetByName("Promoted Links");

 

            context.Load(listTemplate);

 

            // Execute the query to the server

            context.ExecuteQuery();

 

            // Create a new object for ListCreationInformation class - used to specify the properties of the new list

            ListCreationInformation creationInfo = new ListCreationInformation();

 

            // Specify the promoted links list title

            creationInfo.Title = "Custom Promoted Links";

 

            // Specify the promoted links list description

            creationInfo.Description = "My Custom Promoted Link4 List";

 

            // Set a value that specifies the feature identifier of the feature
            that contains the list schema for the new list.

            creationInfo.TemplateFeatureId = listTemplate.FeatureId;

 

            // Set a value that specifies the list server template of the new list

            creationInfo.TemplateType = listTemplate.ListTemplateTypeKind;

 

            // Add the new task list to the list collection

            web.Lists.Add(creationInfo);

 

            // Execute the query to the server

            context.ExecuteQuery();

 

        }

    }

}


Summary:

Custom Promoted Links list is created successfully. Thus in this article you have seen how to create a Promoted Links list in SharePoint 2013 using client side object model.

Ebook Download
View all
Learn
View all