10

On the UI, for a document Library settings, under "Enterprise Metadata and Keywords Settings" there is an option to

"Save metadata on this list as social tags"

Is there a way to activate this, either on an event receiver or on the list definition?

Thanks!

10

So, after a few weeks on and off trying to figure this one out, having no luck with any replies on any forum, I just thought I would have a look at how the UI page was doing this. (Why didn't I think of this earlier?!)

That's when the property EnableMetadataPromotion showed up.

Having this keyword to search for, it didn't take me long to google the missing pieces and come up with this solution:

    internal static void UpdateEnterpriseKeywordSettings(SPList list, bool enableKeyWords, bool promoteToSocial)
    {
        Assembly taxonomyAssembly = Assembly.Load("Microsoft.SharePoint.Taxonomy, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");

        Type listFieldSettings = taxonomyAssembly
                                .GetType("Microsoft.SharePoint.Taxonomy.MetadataListFieldSettings");

        ConstructorInfo constructorInfo = listFieldSettings.GetConstructor(new[] { typeof(SPList) });
        if (constructorInfo != null)
        {
            object listSettings = constructorInfo
                .Invoke(new object[] { list });

            listFieldSettings.GetProperty("EnableMetadataPromotion", BindingFlags.NonPublic |
                                                                     BindingFlags.Instance).SetValue(listSettings, promoteToSocial, null);

            listFieldSettings.GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance)
                .Invoke(listSettings, null);
        }
    }

Hope it will help someone

  • 3
    I was expecting to get my 50 points bounty back, and from what I could read on the meta forum I was not the only one :-( Noob's mistake. Cry and move on... at least I got a badge :-) – Jorge Carvalho Oct 15 '11 at 9:52
  • 1
    Oh well... have a +1 to ease the pain. Thanks for researching this and posting the solution. :) – Kit Menke Oct 15 '11 at 15:45
1

Actually, by adding a the Enterprise Keywords as Metadata colum to a custom content type, which you then bind to your list/library, this shall be available automatically!

0

Go to the list or library for which you want to add an Enterprise Keywords column. On the List or Library tab of the ribbon, click List Settings or Library Settings. Under Permissions and Management, click Enterprise Metadata and Keywords Settings. In the Add Enterprise Keywords section, select the check box to add an Enterprise Keywords column and enable keyword synchronization. Click OK.

Found here:

0

Try here: Programmatically enable Enterprise keywords in SharePoint 2010

This is, of course, after activating the metadata feature.

  • Thanks. I've got the EK working, and I'm also already setting the location based default values. It's just the saving as social tags that is missing from the event receiver and still requiring going through the UI, which is not really a nice option for hundreds if lists :-( – Jorge Carvalho Sep 29 '11 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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