Correct taxonomy field to use in EditModePanel?
-
16-10-2019 - |
Question
We have a SharePoint 2010 content type with a ManagedMetaData field bound to a custom TermStore/Set in the Managed Metadata Service.
We are using an EditModePanel on the PageLayout for the content type and I can't get the correct field to show for the taxonomy picker.
I've added a TaxonomyWebTaggingControl but it appears that I need to hardcode the SSPId and TermSetId values in the layout, which I can't do as I don't know them.
In the Feature which contains the content type we have an event receiver which binds the field to the termset but which control do I need to use in the pagelayout to allow this to be edited?
(It works fine if I edit an item directly from the list using the default SharePoint form).
Solution
I got this working in the end. There's a helpful post here:
Basically you have to add a note column and use TaxonomyField.TextFieldId to point your Taxonomy field to the note field.
I was also using the wrong control in my Page layout, I should have used a TaxonomyFieldControl, not a TaxonomyWebTaggingControl.
OTHER TIPS
I am intereseted in knowing this aswell. I am basicly doing the exact same thing. Seeing as I dont have a code behind page for my page layout I have not found a good way to this.
Previously I have used it within web parts og application pages. I dont know if this will help you but the code I have used for connecting to the service is this:
SPContext context = SPContext.Current;
SPSite site = context.Site;
TaxonomySession session = new TaxonomySession(site);
TermStore termStore =
session.TermStores["Managed Metadata Service"];
Group group = termStore.Groups["groupname"];
TermSet productsTermSet = group.TermSets["termsetname"];
enheterTaxonomyTagger.SspId.Add(termStore.Id);
enheterTaxonomyTagger.TermSetId.Add(productsTermSet.Id);
enheterTaxonomyTagger.IsAddTerms = false;
enheterTaxonomyTagger.AllowFillIn = false;
enheterTaxonomyTagger.IsMulti = true;
portefoljeTaxonomyTagger.SspId.Add(termStore.Id);
portefoljeTaxonomyTagger.TermSetId.Add(productsTermSet.Id);
portefoljeTaxonomyTagger.IsAddTerms = false;
portefoljeTaxonomyTagger.AllowFillIn = false;
portefoljeTaxonomyTagger.IsMulti = false;