0

I need to create a SharePoint Feature, when activated needs to create a Document Library and then enable the manual declaration as record. Following is the code which is working fine in a Console Application but not through Feature.

[Note:- I have been using a Sandbox solution for this purpose]

string ListTitle = "Sample List";

string strRecordCenterURL = "URL";

using (SPSite oSite = new SPSite(strRecordCenterURL))
{
    using (SPWeb oWeb = oSite.OpenWeb())
    {
        SPList oList = oWeb.Lists.TryGetList(ListTitle);
        if (oList == null)
        {
            Guid nKMListGuid = oWeb.Lists.Add(ListTitle, "Description", SPListTemplateType.DocumentLibrary);
            oList = oWeb.Lists[nKMListGuid];
            oList.OnQuickLaunch = true;
            oList.Update();
            oWeb.Update();
        }
        if (oList.RootFolder.Properties.Contains("ecm_IPRListUseListSpecific"))
        {
            oList.RootFolder.Properties["ecm_IPRListUseListSpecific"] = "True";
        }
        else
        {
            oList.RootFolder.Properties.Add("ecm_IPRListUseListSpecific", "True");
        }

        if (oList.RootFolder.Properties.Contains("ecm_AllowManualDeclaration"))
        {
            oList.RootFolder.Properties["ecm_AllowManualDeclaration"] = "True";
        }
        else
        {
            oList.RootFolder.Properties.Add("ecm_AllowManualDeclaration", "True");
        }

        oList.RootFolder.Update();
        oList.Update();
        oWeb.Update();
    }
}
  • what errors are you receiving? – ironman Sep 14 '12 at 14:31
  • I am not getting any errors while activating the feature. – suryakiran Sep 17 '12 at 5:33
0

This seems to be a limitation in Sand-boxed solution. Modified the sand-boxed solution to a Farm-based solution, it is working as expected.

So below is the conclusion from this post

We cannot set the properties of Root Folder of the SPList object using Sand-boxed solution. This can be performed only by a farm based solution even though Sand-boxed solution would not raise any exception

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.