3

I need to add some items to sharepoint list definition, so I need to have the list with columns and items, and then allow users to create the list from the UI. How do I include items in list definition?

  • You can use custom list template for that. It will be available in the add new app section. – Dikesh Gandhi Nov 29 '16 at 4:32
  • How do I do that in visual studio? – Jacky Nov 29 '16 at 4:39
  • You need to create Custom Columns, Add List Definition and List Instance. In the list instance you can Add the Items. – Ram Nov 29 '16 at 4:40
  • This link will give you some idea: sharepoint.stackexchange.com/questions/33576/… – Dikesh Gandhi Nov 29 '16 at 4:41
4

You can do this as follow-

  • Add Site Columns to the custom Solution in the Visual Studio.
  • Add The Content Type if Required.
  • Create List Definitions & Associate the Content Type to the List (If required).
  • Add the List Items in the List Instance by default. In the Items Here
  • Deploy this solution & you can see the List with default items.

For the reference Click Here & Here & Here.

This Link will give in details step by step with the Screenshots.

Hope this will help you.

  • I know how to do all of this. I don't want to create the list, users will create the lists with predefined items .. – Jacky Nov 29 '16 at 5:31
  • Yes, You just create this & save it as an List Template. User need to click => Add an App => Select the List Template Which you have created & uploaded to Template Gallery. Then all the default items will be created on the creation of List by any one of user. – Ram Nov 29 '16 at 5:36
  • I need something in visual studio, as said in my question, I need it in list definition to be packaged, I don't want any manual work .. – Jacky Nov 29 '16 at 5:48
  • I have not yet done this with Visual Studio, But might be there is something to do. But as I know the List Template you need to create it as above steps and while any User create => Add an App => that time user can get the default items which are added in the list instance. – Ram Nov 29 '16 at 6:52
  • Hey, If you got answer please post it! – Ram Dec 1 '16 at 18:49
2

If you add list using ListInstance then you can add items using ListInstance file:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <ListInstance Title="LinkList" OnQuickLaunch="TRUE" TemplateType="170" FeatureId="Your feature id" Url="Lists/LinkList" Description="Your description">
<Data>
  <Rows>
    <Row>
      <Field Name="Title">About</Field>
      <Field Name="Description">Description</Field>
      <Field Name="LinkLocation">http://testlink.com</Field>
      <Field Name="BackgroundImageLocation">
        /sites/Images/tile_about.png</Field>
      <Field Name="LaunchBehavior">New tab</Field>
      <Field Name="Order">2</Field>
    </Row>
  </Rows>
</Data>
</ListInstance>  
</Elements>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.