Question

I have a SharePoint Hosted App. Now I am adding a new list using "Add -> New Item -> Lists".

List got created. But my question is, I want to add an item so that when I install my SharePoint App, the list should create with that default item.

Is this possible? If yes please suggest some work arounds.

Was it helpful?

Solution

Yes it absolutely possible like the good ole days of SSOM.

Go to the your listinstance.xml > elements.xml as below:

enter image description here

Then inside the xml, structure add your data as below:

<ListInstance Title="List1"
                OnQuickLaunch="TRUE"
                TemplateType="100"
                Url="Lists/List1"
                Description="My List Instance">

    <Data>
      <Rows>
        <Row>
          <Field Name="Title">Test1</Field>
        </Row>
        <Row>
          <Field Name="Title">Test2</Field>
        </Row>
        <Row>
          <Field Name="Title">Test2</Field>
        </Row>
      </Rows>
    </Data>

  </ListInstance>

Here, the default values should be inside <Data><Rows><Row>. After that, just deploy your app and default values would be present.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top