Programmatically create Promoted Links list in SharePoint 2013


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.]

In this blog you will see how to create Promoted Links list in SharePoint 2013 using server 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.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;

 

namespace CreatePromotedLinksList

{

    /// <summary>

    /// Console Application

    /// Create a new Promoted Links list

    /// </summary>

    class Program

    {

        static void Main(string[] args)

        {

            // String Variables to store the list name, description and template name

            string listName = "Custom Promoted Links";

            string listDescription = "Promoted Links list created using object model";

            string listTemplateName = "Promoted Links";

            string siteURL = "http://c4968397007/";

 

            using (SPSite site = new SPSite(siteURL))

            {

                using(SPWeb web=site.OpenWeb())

                {

                    // Get the list template

                    SPListTemplate listTemplate = web.ListTemplates[listTemplateName];

 

                    // Create a new Promoted Links list

                    web.Lists.Add(listName, listDescription, listTemplate);

 

                }

            }

        }

    }

}       

                


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 server object model.