Moving Documents in Sharepoint with Metadata via code
- By InfoMajesty Inc on May 3, 2012
- Posted in: Sharepoint 2010 Move Document Archive Metadata
During the develpment of one our workflow projects, there was a requirement to move a user uploaded file from the original Sharepoint 2010 Library to an Archive Library. After researching and having implemented a working solution, we thought this post would benefit others in a similar situation.
Basically, we have used the Sharepoint CopyService Web Service method GetItem method to get the document contents, including metadata (columns as well as managed metadata) into an array. The next step is to use the CopyService method CopyIntoItems and specify the source and destination libraries.
// Archive Document
ArchiveDocument(sitePath, docName);
Since we want to Move the Document, the original document will need to be deleted from the Source Sharepoint Library
retVal = DeleteFile(sharePointPath, sitePath, docName, partNumber, status);
Here is the detailed code for all the required methods:
ArchiveDocument Method:
DeleteFile Method:
getListID Method: