2

We're trying to automate a Site Provisoning process but cannot figure out how to activate the Managed Metadata Navigation feature using CSOM.

This is the code we're executing:

        var clientSite = ClientContext.Site;
        var clientSiteFeatures = clientSite.Features;
        ClientContext.Load(clientSiteFeatures);
        ClientContext.ExecuteQuery();

        // Activate the feature
        clientSiteFeatures.Add(featureId, force, scope);
        ClientContext.ExecuteQuery();

The ID we're activating (this is SP2013 online) is '7201d6a4-a5d3-49a1-8c19-19c4bac6e668' - online resources tell us this should be the correct one. However, this is the error we receive:

Feature with Id '7201d6a4-a5d3-49a1-8c19-19c4bac6e668' is not installed in this farm, and cannot be added to this scope.

Activating the feature manually using Site Settings works like a charm, we didn't get any prerequisite warnings. We've tried activating things like publishing and enterprise features, but no luck.

How can we activate the Managed Metadata Navigation feature using CSOM?

  • Can you post how the featureId variable is populated – Amal Hashim Nov 17 '14 at 16:33
1

This error occurs since Metadata Navigation and Filtering (Id: {7201d6a4-a5d3-49a1-8c19-19c4bac6e668}) is a Web level feature but your example is intended for activating a Site level features.

The following example demonstrates how to activate Metadata Navigation and Filtering feature:

using (var ctx = new ClientContext(webUri))
{
    ctx.Credentials = new SharePointOnlineCredentials(userName, securePassword);

    var featureId = new Guid("7201d6a4-a5d3-49a1-8c19-19c4bac6e668");
    var features = ctx.Web.Features;
    features.Add(featureId, true, FeatureDefinitionScope.None);
    ctx.ExecuteQuery();
}

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.