Home > SharePoint > Easiest way to create SharePoint List Definition

Easiest way to create SharePoint List Definition

Playing with SharePoint is always a bit of time consuming but worthy a lot J . Today we will learn the quickest way to create SharePoint list definition.

STEP 1:

  • Open SharePoint UI.
  • Create SharePoint List.
  • Name it.

STEP 2:

  • Create some columns using UI of SharePoint list.
  • Country and City columns are created and can be seen while adding an item in List created from UI.
  • Country is of type Single line of Text, whereas City is of Choice field with some choices in it.

STEP 3:

  • Go to List settings and Save this list as Template.

  • Give it a proper name, in my case, it’s been named as ‘DemoList’.
  • It will be saved in Template Gallery of Site Collection, Navigate to it.
  • Click on it and it will ask to download, save it on the desktop or any location from which you can access it easily.

STEP 4:

  • Access that saved .stp file as it will be saved with extention .stp , in my case it’s DemoList.stp
  • Rename it’s .stp to .cab
  • Extract it and open its manifest.xml in Visual Studio.
  • Press ctrl+f and find ‘UserLists’, under that node you will see <List
    Name … </List>

  • This is the actual SCMEA for the list which is to be used for creating list definition, copy it in notepad and close the manifest.xml

STEP 5:

  • Create New Project of SharePoint 2010 from here we will be using VS2010 and doing some tweaks in the SCHEMA.

  • Select Deploy as Farm Solution

  • Then Add ‘New Item’ and Select List Definition, Moreover name is properly, in my case I named it DemoList.

  • Provide the name of List Definition, I named it SPDemoListDefinition.
  • Select the type of List definition, Remember we created Custom List from UI and we are going to use its SCHEMA so select Custom List and press ‘Finish’

  • If Add a list Instance is clicked then an Instance from the List Definition will be created after the solution is being deployed.

Now you would have ‘SPDemoList’ List definition added in your solution.

Note: – We will be mainly updating the SCHEMA of ‘SPDemoList’.

  • Open Schema.xml and paste the Schema which as extracted earlier and pasted in notepad to Schema.xml of SPDemoList schema.xml


There are many things which are to be modified now, so don’t panic and focus on the modifications.

  • List
    Name={C560CF03-D855-4FD7-89E1-CBE3370ED0F8} : Change it to proper name of list
    which
    exists in Element.xml i.e SPDemoList
  • FeatureId={00BFEA71-DE22-43B2-A848-C05709900100} : Change it to the featureId into which list definition is being wrapped. Rename the feature properly as

    It will be shown in web features and on its activation List Definition will be created. You need to rename its title

Renamed:

  • Url=Lists/DemoList : Change the Url attribute to the proper name of list , We named it SPDemoList to it will be Url=Lists/SPDemoList
  • Find the “Views” section and add WebPartZoneID=”Main”, SetupPath=”pages\viewpage.aspx” attributes to the each View. Change Url attribute to Url=”AllItems.aspx”.
    • <View Name=”{352071D0-7C1E-4AD6-8875-8A11125CCBCF}” BaseViewID=”1″ WebPartZoneID=”Main” SetupPath=”pages\viewpage.aspx” Url=”AllItems.aspx” …>
  • Find the “<Forms>” section and replace three inner “Form” tags with the following.
    • <Form
      Type=DisplayForm
      Url=DisplayForm.aspx
      SetupPath=pages\form.aspx
      WebPartZoneID=Main/>
    • <Form
      Type=EditForm
      Url=EditForm.aspx
      SetupPath=pages\form.aspx
      WebPartZoneID=Main/>
    • <Form
      Type=NewForm
      Url=NewForm.aspx
      SetupPath=pages\form.aspx
      WebPartZoneID=Main/>

Now build and deploy the solution.

  • Create SharePoint List from SPDemoListDefinition and you would have all the fields available in that list which were in the list created with UI. Moreover fields from schema can be added too.
  • Make sure the Feature is active.

  • Now go to Lists à Create and create list from SPDemoListDefiniton

  • Here we Go J

Hope this will help you.

Advertisements
  1. June 20, 2013 at 4:29 pm

    Sir, we are in need of Sharepoint Developer would you refer someone who got an experience of 1 to 5 years for a permanent position in UK based firm.

    Thanks

    Naqvi

    • June 20, 2013 at 4:37 pm

      I have links with SharePoint resources and they resides in Lahore,Pakistan. Would it work for you ?

  2. Tom
    May 20, 2014 at 7:09 am

    I received a plethora of errors trying to follow these instructions. I finally got the list to deploy, but when I try to create an instance I get “Error Cannot complete this action. Please try again. Correlation ID: {bbcf4516-3d84-45f7-86ca-24ba4658a88b}.” Any ideas?

    • May 26, 2014 at 12:55 pm

      Thank you for your feedback , Correlation Id is a reference id about the issue being raised so please check it from ULS Viewer and let me know.

  3. Mrunal
    March 18, 2016 at 6:03 pm

    What if we want to try the same with library

    • March 22, 2016 at 1:27 am

      Dear it should be the similar way, I will share the blog soon.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: