var objWeb = properties.Feature.Parent as SPWeb;
Guid webPublishingGuid = new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb");
SPFeature feature = null;
SPSite site = objWeb.Site;
feature = objWeb.Features[webPublishingGuid];
if (feature == null)
{
SPContentType contentType = objWeb.ContentTypes["Wiki Page"];
SPField field = objWeb.Fields["Keywords"];
SPFieldLink fieldLink = new SPFieldLink(field);
contentType.FieldLinks.Add(fieldLink);
contentType.Update(true);
}
I want to add site column keyword to site content type wiki page. Above is my code I wrote in my FeatureActivated method.
This works when I execute this code in the default site. My problem is it throws an exception that your keyword column is null when I execute that code in sub site or other team sites.