0

I am writing a custom app to interact with a document library. During deployment I have a module to populate the document library with some sample data, however I am not able to populate the Title field for each document.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="DemoCVs" Url="Lists/CVs">
    <File Path="DemoCVs\Jane Doe CV.docx" Url="Jane Doe CV.docx" Type="GhostableInLibrary">
      <Property Name="Title" Value="Jane Doe" Type="string" />
    </File>
    <File Path="DemoCVs\John Smith CV.docx" Url="John Smith CV.docx" Type="GhostableInLibrary">
      <Property Name="Title" Value="John Smith" Type="string" />
    </File>
  </Module>
</Elements>

The documents are successfully uploaded to the library, but the title field is always empty.

If I alter the file attribute to include Name like so

<File Path="DemoCVs\Jane Doe CV.docx" Url="Jane Doe CV.docx" Type="GhostableInLibrary" Name="Jane Doe">

The title is set, however the document name loses its extention. Setting the extension as such

<File Path="DemoCVs\Jane Doe CV.docx" Url="Jane Doe CV.docx" Type="GhostableInLibrary" Name="Jane Doe CV.docx">

Makes the title property empty again.

Is this not the correct method, or have I made a mistake?

1 Answer 1

0

You can add properties using declarative approach only if you add list items into Custom List, not when you add into Document Library.

I recommend adding sample files programmatically.

Or you can add files in XML and then add properties through code. I'd select the first option.

1
  • Thank you for replying. I am not really certain how I would achieve this with a SPHosted App. The lists are instances within the app. I tried running a post-build powershell script but there seems to be no way to pass this script the app-url.
    – greensmith
    Commented Nov 26, 2015 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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