Populate SharePoint Hosted Add-In Lists with Data

I’ve been tinkering with a simple SharePoint Hosted Add-In the last few days that required an assets library to come pre-populated with a collection of images.

A quick google seemed to only return results that referred to lists so I thought I’d put something out there that covered both!

Lists

Lists are relatively straight forward. Once you add your list to the solution, you can declare the rows in the elements file like so:

lists

When the add-in deploys and you hit the list directly you will see that the data is now in there.

jokes

For libraries you must include the files via a module. First add a module to your solution:

module

Then add your images to the module:

module_files

Lastly, alter the elements.xml file to include a Url parameter that points to your library:

module_elements

When your app is deployed the images will get copied into the library:

images