Managed Metadata is a powerful concept introduced in Sharepoint 2010. It allows you to build taxonomic hierarchies and set them as attributes for your Library metadata fields. Retrieving Managed Metadata value fields from a Sharepoint Library in your .Net project can be a bit tricky.
Below is a step by step on successfully retrieved managed metadata field values from a Sharepoint Library:
GetSharePointMetadata - uses Sharepoint Lists web service method GetListItems to retrieve the raw value for your Sharepoint Library managed metadata column. You will need to pass in the itemID of the Sharepoint Library to this method.
ParseMultiValueSelectManagedMetdata - parses the raw value retrieved from Sharepoint and massages it to get the metadata
Helper Methods:
GetFullDataTable - retrieves Sharepoint Document Metadata into a dataset
ConvertZRowToRegularXml - Transforms XML from Sharepoint into XML understandable by Datatable
Include file to transform the xml
FromZRowtoXML.xml
Tuesday, May 8, 2012
Thursday, May 3, 2012
Moving Documents in Sharepoint with Metadata via code
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
Here is the detailed code for all the required methods:
ArchiveDocument Method:
DeleteFile Method:
getListID Method:
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
// Delete Original Document
retVal = DeleteFile(sharePointPath, sitePath,
docName, partNumber, status);Here is the detailed code for all the required methods:
ArchiveDocument Method:
DeleteFile Method:
getListID Method:
Subscribe to:
Posts (Atom)