Question

I have an app that deploys several lists, one of which is a document library.

I would like deploy a default document (help file) with the document library list, is this possible with a SharePoint hosted app?

Was it helpful?

Solution

For anyone wanting to know how to do this...the link below explains all, tested and deployed, it works.

Deploying a Document Library including content using a Feature

Recently I needed to deploy a SharePoint document library as a feature, but with some documents already in it. In my case it was because of demo content, the customer wanted to do some training and needed a pre-filled document library. I can see this useful in other times however, such as including templates for documents, etc.

The solution for this is not difficult, but since I could not find any instructions online for this I thought I'd write a post.

In short, you need to create a feature that includes two components. A list instance based on a document library and then a module with the documents that you want to add to your library. The module has to point to your newly created library and all is well.

Once you have added your new modules (which contains your content) then you need to edit the XML files like so

<?xml version="1.0" encoding="utf-8"?>
  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Name="DemoDocumentContent" Url="Lists/DemoDocuments">
   <File Path="DemoDocumentContent\demo1.docx" Url="demo1.docx" Type="GhostableInLibrary" />
 </Module>
</Elements>

The module URL is the URL of your document library. You can also an the "Name" to the file if you want.

Hope this helps.

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