Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top