I have a feature that adds two site columns to a content type on activation. On deactivation it's supposed to delete them, but I'm getting the following error: "Site columns which are included in content types or on lists cannot be deleted. Please remove all instances of this site column prior to deleting it."
SPWeb web = properties.Feature.Parent as SPWeb; SPContentType cType = web.ContentTypes[Constants.ClientContentTypeName]; cType.FieldLinks.Delete(Constants.DebtMgmtClientID); cType.FieldLinks.Delete(Constants.DebtMgmtCompanyID); cType.Update(); web.Fields.Delete(Constants.DebtMgmtClientID); // This line throws the error web.Fields.Delete(Constants.DebtMgmtCompanyID); I guess I'm doing it in the wrong order. Can anyone help?
Thanks in advance.