With the arrival of the Managed Metadata Service in SharePoint 2010 we know how useful and powerful this concept is to centrally define and manage terms that will be used as attributes for items in
SharePoint.
Using the Term Store in central Admin to create terms is very easy and straight forward. Creating Managed Metadata coulmns using the UI and adding items that use these columns is also a very easy.
However when it comes to managing the Managed metadata service from the client side, what are out options?
Unfortunately the SharePoint client object model does not support working with MMS taxonomy, fortunately SharePoint provides a web service to wotk with managed metadata: TaxonomyClientService.
The TaxonomyClientService provides the following methods:
- – AddTerms
- GetChildTermsInTerm
- GetChildTermsInTermSet
- GetKeywordTermsByGuids
- GetTermSets
- GetTermsByLabel
Creating Terms with the Client Object Model
To add one or more terms to the term store we have to use the TaxonomyClientService.AddTerms() method, this methos takes the following parameters:
[WebMethodAttribute]
public string AddTerms( Guid sharedServiceId, Guid termSetId, int lcid, string newTerms )
- SharedServiceId. TermStore Id of TermSet to add Term in. Type: Guid
- termSetId. Id of the TermSet that will contain the new term. Type: Guid
- lid. The language that the label will be added in. Type: Int
- newTerms. The XML of the new terms to be added. Type: String
The XML for the newTerms parameter has to be in the following format:
<newterms>
<NewTerm label=\”TermValue1\” clientId=\”34\” parentTermid=\”8195c6aa-ce94-4588-9725-33cf96e82bcc\”></NewTerm>
<NewTerm label=\”TermValue2\” clientId=\”34\” parentTermid=\”8195c6aa-ce94-4588-9725-33cf96e82bcc\”></NewTerm>
</newterms>
Using the Method:
The method returns the GUID (in a string form) of the newly added Term.
Get Terms with the Client Object Model
To get a collection of all terms from the a TermSet we can use the TaxonomyClientService.GetTermSets() method, it takes the following parameters:
[WebMethodAttribute]
public string GetTermSets(string sharedServiceIds, string termSetIds, int lcid, string clientTimeStamps, string clientVersions, out string serverTermSetTimeStampXml)
- sharedServiceIds. The ID of the Term Store. Type: String
- termSetIds. The ID of the Term set to get the terms from. Type: String
- lcid. LCID of language that labels will be returned in. Type: Int
- clientTimeStamps. Collection of TimeStamps which are the last edit time of TermSets stored on the client. Type: String
- clientVersions. Collection of versions of the server that each TermSet was downloaded from (always 1 unless the client doesn’t have the TermSet, then it is 0). Type: String
- serverTermSetTimeStampXml. Returns the collection of TimeStamps of the last edit time of each TermSet. Type: String
Using the method:
The output is in the form:
The definition of this XML is: (thanks to Solid Quality)
Container: Container for all TermStores retrieved
TermStore: Term store retrieved by ID
TS: Term set retrieved by ID
a9: TermSet ID
a11: TermSet description
a16: Submision Policy –> true = Open, false =Closed
a12: TermSet name
a68: TermSet contact email
T: Term
a9: Term ID
LS: Label Set. Set of synonyms for Term
TL: Label Term
a32: Label name
DS: Set of descriptions
TD: Term description
a11: Description text
TMS: More information about Term Set
TM:
a24: TermSet Id
a12: TermSet name
a69: True of false. This term has children terms?. If true then appear a69 attribute, else don’t appear it.
a25: Parent Term ID
You can parse this html to get the term data that you’re looking for; for example if you’re looking for the term GUID:
And that’s how we work with the Taxonomy MMS remotely, not as easy as using central admin but at least we have an option for working remotely.
Cheers
K




I’m Karla Ponce, a SharePoint consultant based in Houston. I have been involved in the full life cycle of the software development process and have a great passion for technology and how to apply it to satisfy and improve business operations. One of my passions is SharePoint(of course!) so this blog is created as a way to share my experiences with sharepoint. To know more about me 



