Wednesday, 29 May 2013

SharePoint List with Data

Create a new SharePoint Farm Project

Add a new List Definition and call it JobTitles_LD

Give the List Definition the following Properties
Name: Job Titles
Type: Custom List
Add List Instance: False || True (it's your call)

Add a new list instance and call it JobTitles_LI

Give the list the following properties
  • Name: Job Titles
  • List Type: Job Titles
  • Description: Available Job Titles
  • List URL: Lists/JobTitles
  • Quick Launch: False


Rename feature1 as NewEmployee_WebScoped

Open up the feature manifest
  • Give your feature a title and description
  • Set the scope to web
  • Make sure that your list instance and definitions are in the elements manifest; that it is in the right hand column.


Open up the elements file of your list instance, by default it should look something like this:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="Job Titles"
                OnQuickLaunch="TRUE"
                TemplateType="10000"
                Url="Lists/JobTitles"
                Description="Available Job Titles">
  </ListInstance>
</Elements>
What you’re going to do is add data to it like so
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="Job Titles"
                OnQuickLaunch="TRUE"
                TemplateType="10000"
                Url="Lists/JobTitles"
                Description="Available Job Titles">
    <Data>
      <Rows>
        <Row>
          <Field Name="Title">Application Programmer</Field>
        </Row>
        <Row>
          <Field Name="Title">Business Analyst</Field>
        </Row>
        <Row>
          <Field Name="Title">Software Developer</Field>
        </Row>
        <Row>
          <Field Name="Title">Software Architect</Field>
        </Row>
        <Row>
          <Field Name="Title">Information Architect</Field>
        </Row>
        <Row>
          <Field Name="Title">Information Wizard</Field>
        </Row>
      </Rows>
    </Data>
  </ListInstance>
</Elements>
And that’s it you’re done, deploy your project and you should have a list with your specified data.