Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Metadata not saved

  Asked By: Edward    Date: May 04    Category: Sharepoint    Views: 2010

I try to upload documents to a SharePoint library programmatically
from an separate application.
I guide my code after this:

http://www.spsfaq.com/customising.asp?page=16

'*****************
' Set some metadata on it
oDoc.Title = "Vehicle sale document"
oDoc.Description = "This is a very useful document"
oDoc.Categories = Array(":Vehicles")
oDoc.Keywords = Array("Car", "Vehicle")
oDoc.Author = GetEnvironmentVariable("USERNAME")

oDoc.Property("urn:schemas-microsoft-com:office:office#VehicleType")
=
"Car"

oDoc.Property("urn:schemas-microsoft-com:office:office#VehicleName")
=
"Work car"

oDoc.Property("urn:schemas-microsoft-com:office:office#SaleDate")
=
#11/23/1999#

oDoc.DataSource.Save

'**************

Everything looks fine, the document is saved to library but metadata
info is lost, is not saved to the document. I don't get any error
messages.

Any help with this please?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Kyle Hernandez     Answered On: May 04

This is how I did.

SPFileCollection ospDestFiles =
CreateSPWeb(destURL).Folders[docLibraryFolder].Files;
SPFile ospFile2 = ospDestFiles.Add
(destURL+folderPath,sourceFileContents,true);
SPListItem item = (SPListItem)ospFile2.Item;

((SPListItem)ospFile2.Item)["Title"] = documentTitleLabel.Text.ToString();
.
.

ospFile2.Item.Update();
where CreateWeb returns SPWeb.

 
Didn't find what you were looking for? Find more on Metadata not saved Or get search suggestion and latest updates.




Tagged: