1

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!

2 Answers 2

1

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

0

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);

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.