Schedule items can recur in time, following a specific recurrence pattern. For example an event could be set to occur each Monday, on the third day of each month, and so on. Associate a Recurrence object with an Item instance to specify the time period, pattern, and other properties for the repetition of that item in time.
Once a recurrent item is created in a Calendar instance, the calendar creates multiple occurrences of the item in the time period being visualized. Occasionally you will get references to these occurrences passed as arguments to the calendar events or returned by the calendar methods. Occurrences are instances of the same class as of the item that was set recurrent, however their recurrence state is set to Occurrence - visible through the item's getRecurrenceState method. If a user moves a recurrent event's occurrence in the calendar, thus changing its start or end time, or changes the occurrence text, an exception is created. RecurrenceExceptions contain data about these item instances whose recurrence state is set to Exception.
In order to programmatically create a recurrent pattern on the client, a Recurrence object must be created and then create a new or choose an already existing Item as its Master item. To create a new Recurrence instance, a special Object, containing information about the values of its properties must be passed as argument to the Recurrence constructor.
This is a complete table of the names of the recurrence's properties, which can be set programmatically from the client side:
Name | Value type | Description |
---|---|---|
pattern | Specifies the interval at which recurring events occur. | |
dailyRecurrence | Specifies the type of daily occurrence pattern, when pattern is set to Daily. | |
monthlyRecurrence | Specifies the type of monthly occurrence pattern, when pattern is set to Monthly. | |
yearlyRecurrence | Specifies the type of yearly occurrence pattern, when pattern is set to Yearly. | |
days | Number | Specifies the number of days between two consecutive occurrences of the same event. Used when pattern is set to Daily. |
weeks | Number | Specifies the number of weeks between two consecutive occurrences of the event. Used when pattern is set to Weekly. |
daysOfWeek | Specifies the days of the week when the event occurs. Used when pattern is set to Weekly. | |
dayOfMonth | Number | Specifies the day of the month when the event occurs. Used when pattern is set to Monthly or Yearly. |
months | Number | Specifies the number of months between two consecutive occurrences of the same event. Used when pattern is set to Monthly. |
occurrence | Specifies on which occurrence of the week within the month the event occurs. Used when pattern is set to Monthly or Yearly and the monthlyRecurrence or yearlyRecurrence properties are set to ByDayType or ByDayType. | |
day | Specifies the day of the week when the event occurs. Used when pattern is set to Monthly or Yearly and the monthlyRecurrence or yearlyRecurrence properties are set to ByDayType or ByDayType. | |
monthOfYear | Number | Specifies the month of the year when the event occurs. Used when pattern is set to Yearly. |
interval | Number | Specifies the number of hours between two consecutive occurrences of the same event. Used when pattern is set to ByTimeInterval. |
recurrenceEnd | Specifies when to stop repeating the recurring event. | |
numOccurrences | Number | Specifies how many times a recurring event should occur. Used when recurrenceEnd is set to NumOccurrences. |
startDate | Specifies the start date of the recurrence series. | |
endDate | Specifies the end date of the recurrence series. Used when recurrenceEnd is set to EndDate. |
To programmatically create and visualize a recurrent event, a Recurrence object must be created and assigned to a newly created or already existing Item in a Calendar. For example:
![]() |
---|
More information about programmatically creating or accessing items on the client side, see here. |
JavaScript
![]() |
---|
function createRecurrentEvent() { |
To assign a new recurrence series to an already existing item, use the editItem method of the Calendar. For example:
JavaScript
![]() |
---|
// the Item object to assign the recurrence series to is passed as parameter to this sample function. |
In order to edit a recurrence pattern, you must first update the original Recurrence object by calling editRecurrence and then update the master Item of the recurrence series by calling editItem. The following example shows how to change the RecurrenceEnd of an existing recurrence:
JavaScript
![]() |
---|
function editRecurrenceSeries(itemWithRecurrence) { |
To remove a recurrent series from an Item, just call editItem and set recurrence to null in the args parameter. Like this:
![]() |
---|
After removing a Recurrence from an Item, the original item used for creating the recurrent series will be restored. To delete the recurrence series and the original item use deleteItem instead (see Manipulating Items on the Client). |
JavaScript
![]() |
---|
// the occurrence parameter is an Item instance, representing an occurrence in the recurrence series to be removed. |
Items, which are part of a recurrence series are easily distinguishable from regular events by checking the value of their getRecurrenceState method. Occurrences defined in the time range, currently presented by the Calendar, can be obtained by calling getItems and filter the result by the master item's id and the occurrence's occurrenceIndex. Exceptions can be retrieved through the getExceptions function.