Tuesday, 5 March 2013

Using Modules to Include Files in the Solution

I have seen lots of people struggle with Modules. Sometimes modules are getting deployed successfully but files are not reflecting in Document library.

First of all the Element.xml file should have below structure.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Module Name="MyCustomModule" Url="SitePages" Path="MyCustomModule">
    <File Url="Sample.aspx" Type="GhostableInLibrary"/>

In above XML few things need to be taken care.

Url ( In Module element): Url in module element indicates the URL of the library where files need be created.

Url (In File element) : The location where the file will be deployed on the SharePoint server

Type: It indicates that whether file is available in Document library as a Item. If this attribute is missing, file would be available under list/libraries but it won’t show up in any of the Views.

Query List/Document Library in Specific Folder

To query SharePoint List or Document Library in specific Folder “ FolderServerRelativeUrl ” as part of the CAML Query Code Snippet ...