Share via


How To: Make SharePoint Calendar events recurring by default

 

This blog post is a contribution from Charls Tom Jacob, an engineer with the SharePoint Developer Support team.

By default, new events added to SharePoint calendar list are not set to be recurring. If all the events users create are going to be recurring, it would be convenient to have this checkbox checked by default, along with some default values populated for the recurrence details.

clip_image001[1]

This can be easily achieved by doing some customization to the list form using SharePoint Designer and JavaScript.

Follow the steps below:

1. Open the list in SharePoint designer

2. Clicks Forms section and click New Item Form from the ribbon

3. Set it as the default form

clip_image003[1]

4. Edit this file in advance mode. Place the following JavaScript after the PlaceHolderMain:

 <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

JavaScript code to set the Recurrence checkbox checked and to set some default value for recurrence.

 <script language="javascript" type="text/javascript">

// Push these methods for execution after the page load

_spBodyOnLoadFunctionNames.push("EnableRecurrence");

_spBodyOnLoadFunctionNames.push("ChangeRecurrenceSettings");

// Utility method to get the HTML element for a sever side control based on a partially matching name

function findHtmlControl(ctrlName) {

var inputs = document.getElementsByTagName("input");

for (var i = 0; i < inputs.length; i++) {

if(inputs[i].id.indexOf(ctrlName) > 0)

return inputs[i]

}

}

function EnableRecurrence() {

// Server generated Id for the checkbox would look like this :

// ctl00$m$g_86f2fc9c_f288_4ea5_8967_96c53e5a8aa5$ff71$ctl00$ctl00$RecurrenceField

var RecurrenceField= findHtmlControl("RecurrenceField");

if(RecurrenceField.checked == false)

{

// Set the checkbox to checked

RecurrenceField.checked = true;

// Fire the click event which initiates a post-back which will display the recurrence details section

RecurrenceField.onclick();

}

}

function ChangeRecurrenceSettings() {

var repeatInstances= findHtmlControl("repeatInstances");

var endDateRangeType= findHtmlControl("endDateRangeType1");

// Select the "End after" option button

if(endDateRangeType != null)

{

endDateRangeType.checked = true;

}

// Set number of occurrences to 12 instead of the default 10

if(repeatInstances != null)

{

repeatInstances.value = 12;

}

}

</script>

5. Save the changes and navigate to the SharePoint site, create a new Event. The form would open with recurrence checkbox checked and “End after” set to 12

clip_image005

Comments

  • Anonymous
    January 01, 2003
    Hi Rajendra, Thanks for the question. Is it happening on every calender list you have? Please try it in a different site collection if you could. You can also post the question to the sharepoint forum here to get a wider audience : social.msdn.microsoft.com/.../home Thanks Charls

  • Anonymous
    September 30, 2013
    Hi,. I created on recurring event with End after 10 occurrences and I observed there are occurrences creating. What it might me the problem ? Can you please share if you have any info about this..? Thanks In advance Rajendra

  • Anonymous
    September 30, 2013
    Hi,. I created on recurring event with End after 10 occurrences and I observed there are 12 occurrences creating. What it might me the problem ? Can you please share if you have any info about this..? Thanks In advance Rajendra

  • Anonymous
    July 08, 2014
    The comment has been removed

  • Anonymous
    February 26, 2015
    When adding this reoccurance feature, it breaks all the tabs that I have set up for my list. Is there a way to keep the tab options too?

  • Anonymous
    October 05, 2015
    The comment has been removed