1

I created a feature receiver whereby on activation will activate and set certain features and its properties. One of that feature is InPlaceRecords. Below is my code in the FeatureActivated method:-

if (!Records.IsInPlaceRecordsEnabled(site))
            {
                //Activate In Place Records Management
                SPFeatureDefinition inPlaceFeature = site.WebApplication.Farm.FeatureDefinitions["InPlaceRecords"];

                if (inPlaceFeature != null)
                {
                    using (SPSite s = new SPSite(site.ID))
                    {
                        s.Features.Add(inPlaceFeature.Id);

                        s.RootWeb.Update();
                    }
                }
            }

            //Record declaration settings
            using (SPSite s = new SPSite(site.ID))
            {
                //set record restriction
                Records.SetRecordDefinitionForSite(s, RecordRestrictions.BlockDelete);

                if (s.RootWeb.Properties.ContainsKey("ecm_SiteRecordDeclarationDefault"))
                {
                    s.RootWeb.Properties["ecm_SiteRecordDeclarationDefault"] = "True";
                }

                if (s.RootWeb.AllProperties.ContainsKey("ecm_siterecordundeclarationby"))
                {
                    s.RootWeb.AllProperties["ecm_siterecordundeclarationby"] = "OnlyAdmins";
                }

                if (s.RootWeb.Properties.ContainsKey("ecm_siterecorddeclarationby"))
                {
                    s.RootWeb.Properties["ecm_siterecorddeclarationby"] = "AllListContributors";
                }

                //Content type publishing hub
                if (s.RootWeb.Properties.ContainsKey("MetadataTimeStamp"))
                {
                    s.RootWeb.Properties["MetadataTimeStamp"] = string.Empty;
                }

                //TODO:activate record search feature

                s.RootWeb.Update();
            }

My problem is during debugging the target properties does not exists (for example ecm_SiteRecordDeclarationDefault). How to perform this task programmatically.

Thanks

Your Answer

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

Browse other questions tagged or ask your own question.