Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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();
    }
}
share|improve this question
    
what errors are you receiving? –  ironman99 Sep 14 '12 at 14:31
    
I am not getting any errors while activating the feature. –  suryakiran Sep 17 '12 at 5:33

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.