1

I'm having a hard time trying fo figure this one out. I can only use Microsoft.Sharepoint.Client for this. I'am working with Sharepoint 2013.

I need to list all Fields (Metadata) For a certain content type that are actually Manage Metadata TermSet fields. I can already get the ContentType and access its Fields. Once there I can find all the TermSet Fields base on Field.TypeAsString just like this :

if (field.TypeAsString == "TaxonomyFieldType" || field.TypeAsString == "TaxonomyFieldTypeMulti")

So What I'm wondering now is How could I get the proper TermStore in order to get the TermSet ? I know I need the TermStore Id, but I didn't find it anywhere in the Field's properties. I'm currently looking at MSDN but didn't find anything yet.

Thanks for any information you can provide!

1 Answer 1

2

I think this will give you what you are looking for...

// get the TaxonomyField from the Site Columns in the sitecollectionTaxonomyField 
field = (TaxonomyField)site.RootWeb.Fields[TAXONOMYFIELDID]; 
// get the Term Store ID from the field
Guid termStoreId = field.SspId; 
// Open a taxonomysession and get the correct termstoreTaxonomy
Session session = new TaxonomySession(site);
TermStore termStore = session.TermStores[termStoreId];

Let me know if this doesn't solve your problem.

2
  • Thanks for the answer, it did point me in the right direction! Microsoft.SharePoint.Client.Field does not have any "SspId" property BUT I finally found it in the "SchemaXml" property along with the TermSetId. With those I can now get the "TermStore -> TermSet -> Term -> Label" structure I need. Just a bit of code to do and I think I should be good! Thanks again
    – Alex
    Feb 20, 2013 at 21:46
  • Cool. Glad you got it figured out! Feb 21, 2013 at 2:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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