1

I have created a simple custom calendar list using a sandboxed solution. I want to use recurring event, but that's not working with my created list, it's showing me an error message.

I am getting the error message as below

Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Value does not fall within the expected range.
at Microsoft.SharePoint.WebControls.RecurrenceField.SetRecurrenceFields()
at Microsoft.SharePoint.WebControls.RecurrenceField.CompleteItemLoad()
at Microsoft.SharePoint.WebControls.SaveButton.ActionBeforeSaveItem(SPContext itemContext)
at Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext itemContext, Boolean uploadMode, String checkInComment)
at Microsoft.SharePoint.WebControls.SaveButton.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


code i have added in event recievere file is as like bellow spinet

enter image description here

and after this i am an adding feature id of site level feature in element.xml file of the list instance,after that i am rebuilding solution,publishing it and then uploading that published .wsp file in SharePoint using solution gallery and after that simple activating the site level feature that's it

10
  • can you share the error? Have you followed the error to the ULS logs?
    – Mike
    Commented Apr 12, 2016 at 11:27
  • okkk,am adding that to question for more clarification
    – Madhav
    Commented Apr 12, 2016 at 11:34
  • Have you looked at this: sharepoint.stackexchange.com/questions/73349/…
    – Mike
    Commented Apr 12, 2016 at 11:52
  • yes i did??but the solution is marked as answered that i am not able to understand means that's not clear to me.
    – Madhav
    Commented Apr 12, 2016 at 11:54
  • Feature Activated class will already be there in your event receiver. Please uncomment the class & add the code within that class & you are done.
    – Hardik
    Commented Apr 13, 2016 at 7:15

1 Answer 1

1

Please check below image for reference

enter image description here

Instead of creating the calendar through a feature element, You have to user c# code to create Calendar list from Event Receiver.

You can use below mentioned code in your FeatureActivated class in your feature event receiver.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {


                SPSite site = new SPSite(SPContext.Current.Site.ID);
                SPWeb web = site.OpenWeb(SPContext.Current.Web.ID);
                SPList listExistCheck = web.Lists.TryGetList("Calendar List");
                SPList customList;
                if (listExistCheck == null)
                {
                    // Create calendar list and record returned guid
                    Guid customPagesListGuid = web.Lists.Add("Calendar List", "Calendar List", SPListTemplateType.Events);
                    //Get list from stored guid
                    customList = web.Lists[customPagesListGuid];
                    // Set list properties and add required content types

                    customList.Title = "Calendar List";
                    customList.OnQuickLaunch = true; // Set to true to display on the quick launch
                    customList.ContentTypesEnabled = true;
                    customList.Update();
                    customList.Update();
                    web.Update();
                }

        }
30
  • sorry hardik ,I am very new to share point and that's why asking some stupid kind of questions.actually working with this event receiver here i have two features one for site level features and another one for site collection features,so where at which feature exactly i have to add the event receiver ??
    – Madhav
    Commented Apr 12, 2016 at 13:29
  • Site level Feature
    – Hardik
    Commented Apr 12, 2016 at 13:33
  • here at the SPSecurity. i am getting error,it says "the name SPSecurity does not exist in the current context"
    – Madhav
    Commented Apr 12, 2016 at 13:38
  • you need to add the namespace called Microsoft.SharePoint
    – Hardik
    Commented Apr 12, 2016 at 13:40
  • that's already present there
    – Madhav
    Commented Apr 12, 2016 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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