Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a web service that shows a sort of CRUD of document (with metadata) for other application..

I have some document libraries in which users can upload (via WS) documents with metadatas.

For every kind of documents the upload of a new file works fine but when I upload new versions of particular file (DOCX, PPTX..) the metadata disappears in the new versions!

So.. how can I fix this problem? Is a well known bug or something new I have found?

Thank you very much!

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

I solved my problem simply "rewriting down" the data inserted in the old item field.

Supposing my custom columns are:

  • tt_file_id
  • tt_content_id
  • tt_Name

The code is:

SPListItem oldItem = list.GetItemById(OldItemID);
SPListItem newFile = (list.RootFolder.Files.Add(oldItem["Name"].ToString(), filebytes, true)).ListItemAllFields;

string Name = oldItem["Name"].ToString();
newFile["tt_file_id"] = oldItem["tt_file_id"];
newFile["Name"] = oldItem["Name"];
newFile["tt_content_id"] = oldItem["tt_content_id"];

newFile.SystemUpdate(false);
share|improve this answer
add comment

check this link out on msdn forum as its the same question:

For the ones (.docx / .xlsx) if you add metadata; you download the document and upload it back again you will notice the field values will be pre-populated and this is because of XML promotion and demotion. To verify this:
Step 1: change the extension of your .docx or .xlsx to .zip
Step 2: Open the zip file and look for a folder customXml
Step 3: Open the folder and look for a file Item1.xml
When you open the file you will notice that the properties have the same values as were assigned when you first uploaded the document. This is the exact reason why you get the fields pre-populated once you upload this document. The above process is what is called as XML promotion and demotion. Hope this gives you an idea on what this is.

Note: The above steps won't be true for .doc or .xls, for these types of documents you will notice that fields are always empty.

http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/1b115343-20e5-4962-af97-793194f07637

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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